/*! wx-card 2019-03-08 */
define("/common/js/app", [ "router" ], function(require, exports, module) {
    var router = require("router");
    //注册组件 , 帖子列表
    var app = function(params) {
        app.wxLoad = null;
        //app.wx = require("jweixin");
        app.params = {
            versions: "6.7",
            userVersions: "2.4",
            urlChangeFromComponent: 1,
            debug: true,
            urlCache: {},
            loadPage: 0,
            plugUrl: "/",
            apiDomain: "http://tenement.com/",
            //不带"/"
            //domain: 'http://www.codecamp.com', 
            loginUrl: "https://login.bestsmartbee.com/"
        };
        for (var i in params) {
            app.params[i] = params[i];
        }
        app.pageData = {};
        var fun = {
            setWxShareData: function() {
                if (!app.isWeiXin()) {
                    return;
                }
                if (app.params.DefShareData) {
                    app.wxDefShare(app.params.DefShareData);
                } else {}
            },
            isWeiXin: function() {
                //window.navigator.userAgent属性包含了浏览器类型、版本、操作系统类型、浏览器引擎类型等信息，这个属性可以用来判断浏览器类型
                var ua = window.navigator.userAgent.toLowerCase();
                //通过正则表达式匹配ua中是否含有MicroMessenger字符串
                if (ua.match(/MicroMessenger/i) == "micromessenger") {
                    return true;
                } else {
                    return false;
                }
            },
            isAlipay: function() {
                //window.navigator.userAgent属性包含了浏览器类型、版本、操作系统类型、浏览器引擎类型等信息，这个属性可以用来判断浏览器类型
                var ua = window.navigator.userAgent.toLowerCase();
                if (ua.match(/Alipay/i) == "alipay") {
                    return true;
                } else {
                    return false;
                }
            },
            //实例化VueApp
            init: function() {
                //创建和挂载根实例
                var VueApp = new Vue({
                    router: router,
                    watch: {
                        // 如果路由有变化，会再次执行该方法
                        $route: "fetchData"
                    },
                    mounted: function() {
                        this.fetchData();
                        app.setWxShareData();
                    },
                    methods: {
                        fetchData: function() {
                            //  console.log(this.$route);
                            var name = this.$route.name;
                            var options = app.findOptionsByName(name);
                            if (!options.name) {
                                return;
                            }
                            var hash = window.location.hash;
                            if (hash && hash.indexOf("component_") > -1) {
                                return false;
                            }
                            var id = "#page" + app.ucfirst(name);
                            var wrap = "#router-view-tmp";
                            //页面是要缓存的
                            if (options.page == "cache") {
                                wrap = "#router-view-cache";
                            } else {
                                wrap = "#router-view-tmp";
                                // 如果是组件路由发生变化，不清缓存
                                // if(app.params.urlChangeFromComponent==1){
                                //     $(wrap).html("");
                                // }
                                // console.log(app.params.preRoute);
                                // if ($(id).length > 0  && $(id).attr('url') !=window.location.href) {
                                //    var url = $(id).attr('url');
                                //    $(id).remove();
                                // }
                                if ($(id).length > 0) {
                                    $(id).remove();
                                }
                            }
                            if ($(id).length > 0 && $(id).attr("url") != window.location.href) {
                                var url = $(id).attr("url");
                                $(id).remove();
                            }
                            app.params.preRoute = name;
                            $(".page").addClass("cached").removeClass("pageShow");
                            var loadingPage = '<div class="loadingPage" style="text-align: center;margin-top: 100px;">正在为您努力加载页面。。。。</div>';
                            $("body").append(loadingPage);
                            if (options.title) {
                                app.setTitle(options.title);
                            }
                            if ($(id).length > 0) {
                                $(id).removeClass("cached").addClass("pageShow");
                                $(".loadingPage").remove();
                                var pageVm = app.getVm(name);
                                if (pageVm) {
                                    typeof pageVm.pageShow === "function" ? pageVm.pageShow() : "";
                                }
                                if (typeof app.pageShow == "function") {
                                    app.pageShow({
                                        name: name,
                                        vm: pageVm
                                    });
                                }
                            } else {
                                app.routePage(name, wrap);
                            }
                        }
                    }
                }).$mount("#app");
                if (typeof app.afterInit == "function") {
                    app.afterInit();
                }
            },
            // 加载组件
            component: function(name, params) {
                // app.params.urlChangeFromComponent=1;
                require.async("/component/template_js/" + name, function(html) {
                    // console.log(html);
                    var id = "component_" + name;
                    app.popup(id, html, "body");
                    window.location.href = "#" + id;
                    $(".popupBg").remove();
                    require.async("/component/" + name, function(component) {
                        component.vue(params);
                        // app.params.urlChangeFromComponent=0;
                        $("#" + id).addClass("page").addClass("popup_page");
                    });
                });
            },
            wxShare: function(params, callblack) {
                var data = {
                    title: params["title"],
                    // 分享标题
                    link: params["url"] ? params["url"] : window.location.href,
                    // 分享链接
                    imgUrl: params["imgUrl"],
                    // 分享图标
                    desc: params["desc"],
                    success: function() {},
                    cancel: function() {}
                };
                app.wx(function(wx) {
                    // console.log(data);
                    wx.onMenuShareTimeline(data);
                    wx.onMenuShareAppMessage(data);
                    callblack ? callblack() : "";
                });
            },
            wx: function(callblack) {
                require.async("jweixin", function(wx) {
                    app.wx = wx;
                    typeof callblack == "function" ? callblack(wx) : "";
                });
            },
            //传入一个name ， 会加载对应的html ,和js , 生成id : page-id
            routePage: function(name, wrap, ajax) {
                if (!name) {
                    return false;
                }
                // console.log(name);
                // component
                // 默认的
                if (!wrap) {
                    wrap = "#router-view-tmp";
                }
                var id = "page" + app.ucfirst(name);
                console.log("template_js/" + name);
                require.async("template_js/" + name, function(content) {
                    if (typeof content == "string") {
                        content = content.replace(/<img/g, "<img onerror=\"javascript:this.src='https://img.bestsmartbee.com/1536138807127'\" ");
                    }
                    var url = window.location.href;
                    if (ajax == 1) {
                        content = $("<div>" + content + "</div>").find(".ajaxPageContent").html();
                        content = "<div url=" + url + " id='" + id + "'>" + content + "</div>";
                    } else {
                        content = "<div url=" + url + " class='page pageShow' id='" + id + "'>" + content + "</div>";
                    }
                    var wrapContent = $(content);
                    $(wrapContent).hide();
                    $(wrapContent).appendTo(wrap);
                    var pageId = "#" + id;
                    var options = {
                        name: name
                    };
                    // console.log("js/" + name);
                    require.async("js/" + name, function(controller) {
                        // console.log(options);
                        // console.log(options,controller.pageShow);
                        controller.vue(options);
                        var vm = controller.vm;
                        $(pageId).show();
                        $(".loadingPage").remove();
                        if ($(pageId).find(".page-content").length > 0) {
                            app.scrollPreventDefault($(pageId).find(".page-content").eq(0));
                        }
                        if (typeof vm.pageShow == "function") {
                            vm.pageShow(options);
                        }
                        if (typeof app.pageShow == "function") {
                            options.vm = controller.vm;
                            app.pageShow(options);
                        }
                    });
                });
            },
            //禁用滚动
            scrollPreventDefault: function(pageContent) {
                function pageContentTouchstart() {
                    var el = this;
                    var top = el.scrollTop, totalScroll = el.scrollHeight, currentScroll = top + el.offsetHeight;
                    if (top === 0) {
                        $(el).attr("_isScroller", 1);
                        el.scrollTop = 2;
                    } else if (currentScroll === totalScroll) {
                        $(el).attr("_isScroller", 1);
                        el.scrollTop = top - 2;
                    }
                }
                function pageContentTouchmove() {
                    var el = this;
                    var top = el.scrollTop, totalScroll = el.scrollHeight, currentScroll = top + el.offsetHeight;
                    if (top === 0) {
                        $(el).attr("_isScroller", 0);
                    } else if (currentScroll === totalScroll) {
                        $(el).attr("_isScroller", 0);
                    }
                }
                function preventDefault(evt) {
                    var _isScroller = $(".pageShow .page-content").attr("_isScroller");
                    //pageContent 滚动到底部或顶部时禁用滚动
                    if (_isScroller == "0") {
                        evt.preventDefault();
                    }
                }
                //判断pageContent 滚动的位置， 如果滚动到顶部或底部， 禁用滚动
                $(pageContent).unbind("touchstart", pageContentTouchstart).bind("touchstart", pageContentTouchstart);
                $(pageContent).unbind("touchmove", pageContentTouchmove).bind("touchstart", pageContentTouchmove);
                //当pageContent顶部或底部， body是不能能滚动
                $("body").unbind("touchmove", preventDefault).bind("touchmove", preventDefault);
                //评价用户作品添加滚动效果
                // $(".add-comment-info").on("touchmove", function(event) {
                //     event.stopPropagation();
                // });
                // $(".add-comment-info").on("touchend", function(event) {
                //     event.stopPropagation();
                //     document.body.scrollTop = 0;
                // });
                //头部不能能滚动
                $("#header").unbind("touchmove").bind("touchmove", function(evt) {
                    evt.preventDefault();
                });
                //底部不能能滚动
                $(".bottom-fixed").unbind("touchmove").bind("touchmove", function(evt) {
                    evt.preventDefault();
                });
            },
            //找到这路由的配置
            findOptionsByName: function(name) {
                var options = router.options.routes;
                for (var item in options) {
                    if (name == options[item]["name"]) {
                        return options[item];
                    }
                }
                return {};
            },
            confirm: function(params) {
                //  $(".confirm").remove();
                // $("body").find(".popupBg").remove();
                var confirmText = params.confirmText ? params.confirmText : "确定";
                var cancelText = params.cancelText ? params.cancelText : "取消";
                var html = '<div class="confirm" id="appConfirm">';
                html += '<div class="confirm-text">' + params.text + "</div>";
                html += '<ul class="confirm-options">';
                html += '<li class="bl">' + cancelText + "</li> <li>" + confirmText + "</li>";
                html += "</ul>";
                html += "</div>";
                var yes = params.yes;
                $("body").append(html);
                // if ($("body").find(".popupBg").length > 0) {
                //     $("body").find(".popupBg").remove();
                // }
                $('<div class="popupBg"></div>').insertBefore("#appConfirm");
                $(".popupBg").unbind("click").bind("click", function() {
                    app.confirmNo();
                });
                $("#appConfirm .confirm-options li").eq(0).click(function() {
                    app.confirmNo(params.no);
                });
                var left = $(".confirm").width() / 2;
                $(".confirm").css("margin-left", "-" + left + "px");
                $("#appConfirm .confirm-options li").eq(1).click(function() {
                    app.confirmNo();
                    yes ? yes() : "";
                });
            },
            confirmNo: function() {
                $(".confirm").remove();
                $("body").find(".popupBg").remove();
            },
            //操作选项
            handle: function(params) {
                var optionsHtml = "";
                for (var i in params) {
                    optionsHtml += '<div class="handle-options-one">' + params[i]["text"] + "</div>";
                }
                var html = '<div class="handle-options">';
                html += '<div class="handle-options-group">';
                html += optionsHtml;
                html += " </div>";
                html += '<div class="handle-options-last colse">取消</div>';
                html += " </div>";
                app.popup("handle", html);
                $(".handle-options-one").click(function() {
                    var callblack = params[$(this).index()]["methods"];
                    callblack ? callblack() : "";
                    $("#handle").prev().remove();
                    $("#handle").remove();
                });
            },
            colseHandle: function() {
                $("body").find(".popupBg").remove();
                $("#handle").remove();
            },
            //popup 弹出方式
            popup: function(id, content, container) {
                if ($("body").find("#" + id).length > 0) {
                    $("body").find("#" + id).remove();
                }
                var html = '<div class="popup" id="' + id + '">' + content + "</div>";
                if (container) {
                    $(container).append(html);
                } else {
                    $(".pageShow").append(html);
                }
                app.show_popup("#" + id);
            },
            //
            show_popup: function(popupId) {
                if ($("body").find(".popupBg").length > 0) {
                    $("body").find(".popupBg").remove();
                }
                $('<div class="popupBg"></div>').insertBefore(popupId);
                $(popupId).addClass("popup-modal-in");
                $(".popupBg").bind("click", function() {
                    app.hide_popup();
                });
                $(popupId).find(".colse").bind("click", function() {
                    app.hide_popup();
                });
            },
            hide_popup: function() {
                $(".popup").removeClass("popup-modal-in");
                $("body").find(".popupBg").remove();
            },
            //图片加载延迟
            picLazyLoad: function(imgs, fn) {
                require.async("plug/picLazyLoad", function(picLazyLoad) {
                    picLazyLoad.watch(imgs, fn);
                });
            },
            //copy  //  data-clipboard-text="Just because you can doesn't mean you should — clipboard.js"
            copy: function(id, callblack) {
                require.async("plug/clipboard.min", function(clipboard) {
                    var clipboard = new ClipboardJS(id);
                    clipboard.on("success", function(e) {
                        e.clearSelection();
                        callblack ? callblack(e) : "";
                    });
                    clipboard.on("error", function(e) {
                        callblack ? callblack(e) : "";
                    });
                });
            },
            //首字母大写
            ucfirst: function(str) {
                if (typeof str !== "string") {
                    return "";
                }
                var strs = str.split("/");
                var res = "";
                for (var i in strs) {
                    str = strs[i];
                    //var str = str.toLowerCase();
                    str = str.replace(/\b\w+\b/g, function(word) {
                        return word.substring(0, 1).toUpperCase() + word.substring(1);
                    });
                    res += str;
                }
                return res;
            },
            setTitle: function(title) {
                $("#app-title").text(title);
                $("title").html(title);
            },
            showLoad: function() {
                //$("body").append("<div class='dialog loading'></div>");
                var html = '<div class="loader loader--style1" title="0">';
                html += '<svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"';
                html += ' width="40px" height="40px" viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve">';
                html += '<path opacity="0.2" fill="#000" d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946';
                html += "  s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634";
                html += ' c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z"/>';
                html += '<path fill="#000" d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0';
                html += '   C22.32,8.481,24.301,9.057,26.013,10.047z">';
                html += ' <animateTransform attributeType="xml"';
                html += '  attributeName="transform"';
                html += '  type="rotate"';
                html += ' from="0 20 20"';
                html += ' to="360 20 20"';
                html += ' dur="0.5s"';
                html += ' repeatCount="indefinite"/>';
                html += " </path>";
                html += "</svg>";
                html += "</div>";
                if ($("body").find(".loader--style1").length === 0) {
                    $("body").append(html);
                }
                $(".loader--style1").show();
            },
            hideLoad: function() {
                //$(".loading").remove();
                $(".loader--style1").hide();
            },
            //检查TOKEN 是否过期
            checkToken: function(callblack) {
                app.get("apiv2/user/checkToken", function(res) {
                    if (res.code != 200) {
                        app.delUserInfo();
                        app.auth();
                    } else {
                        callblack ? callblack() : "";
                    }
                });
            },
            login: function(callblack, fields) {
                var backUrl = window.location.href;
                var box_login_code = "";
                var Request = app.GetRequest(backUrl);
                var UserInfo = app.getUserInfo();
                // console.log("UserInfo:",UserInfo);
                if (UserInfo && UserInfo.user_id) {
                    app.checkToken(function() {
                        typeof callblack == "function" ? callblack(UserInfo) : "";
                    });
                } else if (Request && Request.token) {
                    var userInfoUrl = app.params.loginUrl + "index/getUserInfoByToken/?token=" + Request.token;
                    app.showLoad();
                    $.ajax({
                        url: userInfoUrl,
                        //可以不是本地域名 
                        type: "get",
                        data: {
                            fields: fields ? fields : "user_id,store_id,phone,nickname,phone,avatarUrl"
                        },
                        dataType: "jsonp",
                        //jsonp格式访问
                        success: function(data) {
                            if (data.code > 0) {
                                app.alert(data.msg);
                                app.relogin();
                            } else {
                                app.setUserInfo(data.userInfo);
                                app.hideLoad();
                                typeof callblack == "function" ? callblack(data.userInfo) : "";
                            }
                        },
                        error: function() {
                            app.relogin();
                        }
                    });
                } else {
                    // var appId = app.getAppId();
                    // https://login.bestsmartbee.com/index/synclogin?inviteId=0&backUrl=http%3A%2F%2Ftenement.com%2Fadmin%2Fhome%2Findex
                    // console.log(loginUrl);
                    app.auth();
                }
            },
            relogin: function(text) {
                app.confirm({
                    text: text ? text : "授权登录发现异常，是否重新登录？",
                    yes: function() {
                        app.auth();
                    }
                });
            },
            auth: function() {
                var backUrl = window.location.href;
                var search = app.GetRequest(window.location.search);
                var store_id = search.store_id ? search.store_id : 0;
                var loginUrl;
                if (app.isWeiXin()) {
                    loginUrl = app.params.loginUrl + "index/getopenid/?store_id=" + store_id + "&backUrl=" + window.escape(backUrl);
                } else if (app.isAlipay()) {
                    loginUrl = app.params.loginUrl + "index/loginH5ByAlipay/?act=getUserId&store_id=" + store_id + "&backUrl=" + window.escape(backUrl);
                } else {
                    loginUrl = app.params.loginUrl + "index/synclogin/?store_id=" + store_id + "&backUrl=" + window.escape(backUrl);
                }
                // alert(loginUrl);
                window.location.href = loginUrl;
            },
            getStoreId: function() {
                var search = app.GetRequest(window.location.search);
                var store_id = search.store_id ? search.store_id : 0;
                return store_id;
            },
            getStore: function(callback) {
                var store_id = app.getStoreId();
                app.get("api/user/getStore", {
                    store_id: store_id
                }, function(res) {
                    callback ? callback(res.data) : "";
                });
            },
            getAppId: function() {
                var Request = app.GetRequest(window.location.href);
                if (Request.appId) {
                    return Request.appId;
                } else {
                    return "";
                }
            },
            wxJs: function(callblack) {
                if (app.wxLoad) {
                    typeof callblack == "function" ? callblack(app.wx) : "";
                    return;
                }
                app.get("api/wechat_tool/wxJs", function(signPackage) {
                    app.wx(function(wx) {
                        app.wxLoad = 1;
                        wx.config({
                            debug: false,
                            appId: signPackage.appId,
                            timestamp: signPackage.timestamp,
                            nonceStr: signPackage.nonceStr,
                            signature: signPackage.signature,
                            jsApiList: [ "onMenuShareTimeline", "onMenuShareAppMessage", "addCard", "chooseCard", "openCard", "chooseWXPay", "previewImage", "openLocation", "getLocation", "openAddress" ]
                        });
                        wx.ready(function() {
                            //alert(callblack);
                            typeof callblack == "function" ? callblack(wx) : "";
                        });
                        wx.error(function(res) {
                            //alert(callblack);
                            app.wxLoad = 0;
                            app.saveLog(res);
                            app.alert(res.errMsg);
                        });
                    });
                });
            },
            GetRequest: function(url) {
                var theRequest = new Object();
                if (url.indexOf("?") != -1) {
                    var str = url.split("?");
                    str = str[1];
                    var strs = str.split("&");
                    for (var i = 0; i < strs.length; i++) {
                        var v = strs[i].split("=")[1];
                        theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
                    }
                }
                return theRequest;
            },
            alert: function(msg, callblack) {
                //alert("<div class='dialog'>"+msg+"</div>");
                if (typeof msg != "string") {
                    msg = JSON.stringify(msg);
                }
                $("body").append("<div class='dialog'>" + msg + "</div>");
                var width = $(".dialog").width() / 2;
                var h = $(".dialog").height() / 2;
                $(".dialog").css({
                    "margin-left": "-" + width + "px",
                    "margin-top": "-" + h + "px"
                });
                setTimeout(function() {
                    $(".dialog").remove();
                    typeof callblack == "function" ? callblack() : "";
                }, 1e3);
            },
            //版本号
            getVersions: function() {
                return app.params.versions;
            },
            //用户信息
            getUserInfo: function(type) {
                var store_id = app.getStoreId();
                var userVersions = app.params.userVersions + store_id;
                var UserInfo = app.cache(userVersions).get("UserInfo");
                if (UserInfo && UserInfo.token) {
                    //callblack ? callblack(UserInfo) : "";
                    // UserInfo.user_id = 36;
                    // UserInfo.token='cca001ac8014eb17284d9545335abe12';
                    return UserInfo;
                }
                return {};
            },
            setUserInfo: function(userInfo) {
                // var userVersions = app.params.userVersions;
                var store_id = app.getStoreId();
                var userVersions = app.params.userVersions + store_id;
                if (userInfo && userInfo.user_id && userInfo.token) {
                    var search = app.GetRequest(window.location.search);
                    delete search.token;
                    $.extend(userInfo, search);
                    var UserInfo = app.cache(userVersions).set("UserInfo", userInfo);
                }
            },
            delUserInfo: function(userInfo) {
                // var userVersions = app.params.userVersions;
                var store_id = app.getStoreId();
                var userVersions = app.params.userVersions + store_id;
                app.cache(userVersions).rm("UserInfo");
            },
            get: function(url, params, callblack) {
                app.showLoad();
                // console.log(params);
                var args = typeof params == "object" ? params : {};
                callblack = $.isFunction(params) ? params : callblack;
                var UserInfo = app.getUserInfo();
                if (UserInfo && UserInfo.token) {
                    args.token = UserInfo.token;
                }
                app.ajax({
                    type: "GET",
                    dataType: "json",
                    data: args,
                    success: function(res) {
                        // console.log(res);
                        callblack(res);
                    },
                    url: app.params.apiDomain + url
                });
            },
            post: function(url, params, callblack) {
                app.showLoad();
                // console.log(params);
                var args = typeof params == "object" ? params : {};
                callblack = $.isFunction(params) ? params : callblack;
                app.ajax({
                    type: "POST",
                    dataType: "json",
                    data: args,
                    success: function(res) {
                        callblack(res);
                    },
                    url: app.params.apiDomain + url
                });
            },
            loadCss: function(url) {
                url = app.params.plugUrl + url;
                var css_id = app.base64_encode(url);
                if (!app.params.urlCache[css_id]) {
                    app.params.urlCache[css_id] = css_id;
                    $("head").append('<link href="' + url + '" id="css_id_' + css_id + '" rel="stylesheet" type="text/css" />');
                }
            },
            //无限加载
            pager: function(id, callblack) {
                //$(window).unbind('scroll');
                function pagerContent() {
                    var bot = 100;
                    //bot是底部距离的高度
                    var nDivHight = $(this).height();
                    var nScrollHight = $(this)[0].scrollHeight;
                    var nScrollTop = $(this)[0].scrollTop;
                    if (nScrollTop + nDivHight + bot >= nScrollHight && app.params.loadPage == "0") {
                        $.isFunction(callblack) ? callblack() : "";
                    }
                }
                // console.log(id);
                $(id).find(".page-content").unbind("scroll", pagerContent);
                $(id).find(".page-content").scroll(pagerContent);
            },
            picker: function(id, params) {
                app.loadCss("plug/weui2/css/picker.css");
                // console.log(app.params.plugUrl +"plug/weui2/js/zepto.weui.min.js");
                app.getScript("plug/weui2/js/zepto.weui.min.js", function() {
                    $(id).picker(params);
                });
            },
            datetimePickerWap: function(id, params) {
                app.getScript("plug/weui2/js/zepto.weui.min.js", function() {
                    $(id).datetimePicker(params);
                });
            },
            cityPicker: function(id, params) {
                app.loadCss("plug/weui2/css/picker.css");
                app.getScript("plug/weui2/js/zepto.weui.min.js", function() {
                    app.getScript("plug/weui2/js/picker.city.js", function() {
                        $(id).cityPicker(params);
                    });
                });
            },
            upload: function(obj, callblack) {
                app.loadCss("plug/photo/photo.css");
                require.async(app.params.plugUrl + "plug/photo/photo.js", function(photo) {
                    photo.initUpload($(obj));
                    callblack ? callblack() : "";
                });
            },
            MultipleUpload: function(obj, callblack) {
                app.loadCss("plug/photo/photo.css");
                require.async(app.params.plugUrl + "plug/photo/photo.js", function(photo) {
                    photo.initMultipleUpload($(obj));
                    callblack ? callblack() : "";
                });
            },
            //时间插件
            datetimepicker: function(_this) {
                app.loadCss("plug/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css");
                app.loadCss("plug/bootstrap-datetimepicker/css/datetimepicker.css");
                app.getScript("plug/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js", function() {
                    app.getScript("plug/bootstrap-datetimepicker/js/bootstrap-datetimepicker.zh-CN.js", function() {
                        $(_this).datetimepicker({
                            language: "zh-CN",
                            autoclose: 1,
                            minView: $(_this).attr("data-minview") ? $(_this).attr("data-minview") : 2
                        });
                    });
                });
            },
            lCalendar: function(id) {
                app.loadCss("plug/lCalendar.css");
                app.getScript("plug/lCalendar.min.js", function() {
                    var calendar = new lCalendar();
                    // alert($("#"+id).attr("type"));
                    calendar.init({
                        trigger: "#" + id,
                        type: $("#" + id).attr("data-type") ? $("#" + id).attr("data-type") : "date"
                    });
                });
            },
            _getScript: function(url, callback) {
                var head = document.getElementsByTagName("head")[0], js = document.createElement("script");
                js.setAttribute("type", "text/javascript");
                js.setAttribute("src", url);
                head.appendChild(js);
                //执行回调
                var callbackFn = function() {
                    if (typeof callback === "function") {
                        callback();
                    }
                };
                if (document.all) {
                    //IE
                    js.onreadystatechange = function() {
                        if (js.readyState == "loaded" || js.readyState == "complete") {
                            callbackFn();
                        }
                    };
                } else {
                    js.onload = function() {
                        callbackFn();
                    };
                }
            },
            //加载js
            getScript: function(url, callblack, versions) {
                url = app.params.plugUrl + url;
                app._getScript(url, function() {
                    callblack ? callblack() : "";
                });
            },
            ajax: function(params) {
                var userInfo = app.getUserInfo();
                var userInfoSearch = {};
                var search = app.GetRequest(window.location.search);
                delete search.token;
                if (userInfo) {
                    userInfoSearch = {
                        store_id: userInfo.store_id,
                        token: userInfo.token
                    };
                    if (userInfo.appid) {
                        userInfoSearch.appid = userInfo.appid;
                    }
                    if (userInfo.appid) {
                        userInfoSearch.openid = userInfo.openid;
                    }
                }
                // console.log(userInfoSearch);
                // return;
                $.extend(userInfoSearch, search);
                params = params ? params : {};
                if ($.isArray(params["data"])) {
                    for (var i in params["data"]) {
                        // userInfoSearch.push({
                        //       name:i,
                        //       value:params["data"][i]
                        //   });
                        userInfoSearch[params["data"][i]["name"]] = params["data"][i]["value"];
                    }
                    params["data"] = userInfoSearch;
                } else {
                    $.extend(userInfoSearch, params["data"]);
                    params["data"] = userInfoSearch;
                }
                console.log(userInfoSearch);
                var ajaxTimeoutTest = $.ajax({
                    url: params["url"],
                    type: params["type"],
                    dataType: params["dataType"],
                    data: params["data"],
                    cache: false,
                    timeout: 1e4,
                    beforeSend: function() {
                        app.showLoad();
                    },
                    success: function(result) {
                        var success = params["success"];
                        typeof success == "function" ? success(result) : "";
                    },
                    complete: function(msg, status) {
                        // console.log(msg.response);
                        app.hideLoad();
                        if (status == "timeout") {
                            //超时,status还有success,error等值的情况                       　　　　　
                            ajaxTimeoutTest.abort();
                            app.alert("由于网络原因，请求超时，请刷新网页试试");
                            app.saveLog("由于网络原因，请求超时，请刷新网页试试");
                        }
                        if (params["cache"]) {
                            var key = app.base64_encode(params["url"]);
                            var result = msg.response;
                            app.params.urlCache[key] = result;
                            app.cache().set(key, result);
                        }
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        app.saveLog(errorThrown);
                        console.log(errorThrown);
                    }
                });
            },
            //保存错误日志
            saveLog: function(msg) {
                console.log(msg);
            },
            //轮播图
            swiper: function(id) {
                app.loadCss("plug/Swiper-4.4.2/css/swiper.min.css");
                app.getScript("plug/Swiper-4.4.2/js/swiper.min.js", function() {
                    var swiper = new window.Swiper("#" + id, {
                        pagination: "#" + id + " .swiper-pagination",
                        //nextButton: '#swiper_<{$data.name}> .swiper-button-next',
                        //prevButton: '#swiper_<{$data.name}> .swiper-button-prev',
                        loop: true,
                        spaceBetween: 30,
                        centeredSlides: true,
                        autoplay: 5e3
                    });
                }, false);
            },
            //页面切换
            swiperPage: function(id, callblack) {
                //  app.loadCss("plug/Swiper-3.3.1/swiper.css");
                app.getScript("plug/Swiper-3.3.1/swiper-3.4.1.jquery.min.js", function() {
                    //绑定滚动事件,记住滚动位置
                    // var swiperH=$(id).attr("swiperH");
                    // var swiperT=$(id).attr("swiperT");
                    var pageContent = $(id).parents(".page-content");
                    var swiperWrap = $(id + "-container");
                    $(swiperWrap).find(".swiperTap").find(".active").addClass("scrollActive");
                    $(pageContent).scroll(function(event) {
                        var swiperIndex = $(swiperWrap).find(".swiperTap").find(".scrollActive");
                        var scrollTop = $(this).scrollTop();
                        var scroll = $(swiperIndex).attr("scroll");
                        if (scroll != "0") {
                            $(swiperIndex).attr("scrollTop", scrollTop);
                        }
                    });
                    var swiper = new window.Swiper(id, {
                        pareanContainer: id + "-container",
                        //autoHeight:true,
                        onTransitionStart: function(swiper) {
                            var pageContent = $(id).parents(".page-content");
                            $(pageContent).addClass("overflowhidden");
                            $(swiperWrap).find(".swiperTap li").attr("scroll", "0");
                        },
                        onTransitionEnd: function(swiper) {
                            var activeIndex = swiper.activeIndex;
                            var swiperWrap = $(id + "-container");
                            $(swiperWrap).find(".swiperTap li").removeClass("scrollActive");
                            $(swiperWrap).find(".swiperTap").find("li").eq(activeIndex).addClass("scrollActive");
                            $(swiperWrap).find(".swiperTap li").attr("scroll", "1");
                            $(pageContent).removeClass("overflowhidden");
                        },
                        onSlideChangeEnd: function(swiper) {
                            var activeIndex = swiper.activeIndex;
                            var swiperWrap = $(id + "-container");
                            var scrollTop = $(swiperWrap).find(".swiperTap li").eq(activeIndex).attr("scrollTop");
                            $(id).parents(".page-content").scrollTop(scrollTop);
                            $(pageContent).removeClass("overflowhidden");
                        },
                        onSlideChangeStart: function(swiper) {
                            var activeIndex = swiper.activeIndex;
                            var slideActive = $(id).find(".swiper-slide").eq(activeIndex);
                            $(id).find(".swiper-slide").addClass("swiper-slide-hide");
                            slideActive.removeClass("swiper-slide-hide");
                            var load = slideActive.attr("load");
                            var name = slideActive.attr("name");
                            if (load != 1 && name) {
                                app.routePage(name, slideActive, 1);
                                slideActive.attr("load", 1);
                            }
                            var swiperWrap = $(id + "-container");
                            $(swiperWrap).find(".swiperTap li").removeClass("active");
                            $(swiperWrap).find(".swiperTap li").eq(activeIndex).addClass("active");
                            //alert(callblack);
                            //滚动到原来位置
                            // alert($(slideActive).height());
                            //$(id).height(($(slideActive).height()));
                            callblack ? callblack(swiper) : "";
                        },
                        onTouchMove: function(swiper, e) {
                            var activeIndex = swiper.activeIndex;
                            var container = $(id + "-container");
                            var transform = $(container).find(".swiper-wrapper").css("transform");
                            var w = swiper.width;
                            var li_w = $(container).find(".swiperTap li").eq(activeIndex).width();
                            if (typeof transform == "string" && transform && transform.indexOf("translate3d(") == "0") {
                                if (transform.indexOf("translate3d(") == "0") {
                                    var transforms = transform.substring(13).split(",");
                                    var transformsW = Number(transforms[0].replace(/px/g, ""));
                                    var transform_x = (transformsW - activeIndex * w) / w * li_w;
                                }
                            } else {
                                return false;
                            }
                            $(container).parents(".page").find(".nav-tab-fix li").eq(activeIndex).find(".swiperTapLine").css("left", transform_x + "px");
                            if ($(container).parents(".page").find(".nav-tab-fix li").length) {
                                $(container).find(".swiperTap li").eq(activeIndex).find(".swiperTapLine").css("left", transform_x + "px");
                            }
                        },
                        onTouchEnd: function(swiper, e) {
                            var container = $(id + "-container");
                            var activeIndex = swiper.activeIndex;
                            $(container).find(".swiperTap li").find(".swiperTapLine").css("left", "0px");
                            if ($(container).parents(".page").find(".nav-tab-fix li").length) {
                                $(container).parents(".page").find(".nav-tab-fix li").find(".swiperTapLine").css("left", "0px");
                            }
                        }
                    });
                    //绑定点击事件
                    var length = $(id).find(".swiper-slide").length;
                    $(id + "-container").find(".swiperTap li").click(function(event) {
                        var index = $(this).index();
                        if (length > index) {
                            swiper.slideTo(index);
                        }
                    });
                    if ($(id + "-container").parents(".page").find(".nav-tab-fix li").length) {
                        $(id + "-container").parents(".page").find(".nav-tab-fix li").click(function(event) {
                            var index = $(this).index();
                            if (length > index) {
                                swiper.slideTo(index);
                            }
                        });
                    }
                }, false);
            },
            /*
             * Javascript base64_encode() base64加密函数
             用于生成字符串对应的base64加密字符串
             * 吴先成  www.51-n.com ohcc@163.com QQ:229256237
             * @param string str 原始字符串
             * @return string 加密后的base64字符串
             */
            base64_encode: function(str) {
                var c1, c2, c3;
                var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
                var i = 0, len = str.length, string = "";
                while (i < len) {
                    c1 = str.charCodeAt(i++) & 255;
                    if (i == len) {
                        string += base64EncodeChars.charAt(c1 >> 2);
                        string += base64EncodeChars.charAt((c1 & 3) << 4);
                        string += "==";
                        break;
                    }
                    c2 = str.charCodeAt(i++);
                    if (i == len) {
                        string += base64EncodeChars.charAt(c1 >> 2);
                        string += base64EncodeChars.charAt((c1 & 3) << 4 | (c2 & 240) >> 4);
                        string += base64EncodeChars.charAt((c2 & 15) << 2);
                        string += "=";
                        break;
                    }
                    c3 = str.charCodeAt(i++);
                    string += base64EncodeChars.charAt(c1 >> 2);
                    string += base64EncodeChars.charAt((c1 & 3) << 4 | (c2 & 240) >> 4);
                    string += base64EncodeChars.charAt((c2 & 15) << 2 | (c3 & 192) >> 6);
                    string += base64EncodeChars.charAt(c3 & 63);
                }
                return string;
            },
            /*
             * Javascript base64_decode() base64解密函数
             用于解密base64加密的字符串
             * 吴先成  www.51-n.com ohcc@163.com QQ:229256237
             * @param string str base64加密字符串
             * @return string 解密后的字符串
             */
            base64_decode: function(str) {
                var c1, c2, c3, c4;
                var base64DecodeChars = new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
                var i = 0, len = str.length, string = "";
                while (i < len) {
                    do {
                        c1 = base64DecodeChars[str.charCodeAt(i++) & 255];
                    } while (i < len && c1 == -1);
                    if (c1 == -1) break;
                    do {
                        c2 = base64DecodeChars[str.charCodeAt(i++) & 255];
                    } while (i < len && c2 == -1);
                    if (c2 == -1) break;
                    string += String.fromCharCode(c1 << 2 | (c2 & 48) >> 4);
                    do {
                        c3 = str.charCodeAt(i++) & 255;
                        if (c3 == 61) return string;
                        c3 = base64DecodeChars[c3];
                    } while (i < len && c3 == -1);
                    if (c3 == -1) break;
                    string += String.fromCharCode((c2 & 15) << 4 | (c3 & 60) >> 2);
                    do {
                        c4 = str.charCodeAt(i++) & 255;
                        if (c4 == 61) return string;
                        c4 = base64DecodeChars[c4];
                    } while (i < len && c4 == -1);
                    if (c4 == -1) break;
                    string += String.fromCharCode((c3 & 3) << 6 | c4);
                }
                return string;
            },
            //缓存
            cache: function(v) {
                var versions = v ? v : app.getVersions();
                var cacheFun = {
                    set: function(key, data) {
                        var value;
                        key = key + "_" + versions;
                        if (typeof data == "object") {
                            data = JSON.stringify(data);
                            value = "obj-" + data;
                        } else {
                            value = "str-" + data;
                        }
                        try {
                            localStorage.setItem(key, value);
                        } catch (err) {
                            if (err.name == "QuotaExceededError") {
                                localStorage.clear();
                                //如果缓存已满则清空
                                localStorage.setItem(key, value);
                            }
                        }
                    },
                    rm: function(key) {
                        key = key + "_" + versions;
                        localStorage.removeItem(key);
                    },
                    get: function(key) {
                        key = key + "_" + versions;
                        var value = localStorage.getItem(key);
                        if (value == null) {
                            return null;
                        }
                        var type = value.substr(0, 4);
                        if (type == "str-") {
                            return value.substr(4);
                        }
                        if (type == "obj-") {
                            var data = value.substr(4);
                            return $.parseJSON(data);
                        }
                    },
                    clear: function() {
                        localStorage.clear();
                    }
                };
                return cacheFun;
            },
            //微信默认分享
            wxDefShare: function(params) {
                if (typeof params == "undefined") {
                    var wxShareData = {
                        title: "跟着普象君有肉吃",
                        // 分享标题
                        imgUrl: "https://www.lgstatic.com/thumbnail_300x300/image1/M00/00/47/Cgo8PFTUXOOAbTbtAAA-0t30W6k220.jpg",
                        // 分享图标
                        desc: "等你好久了，终于来了"
                    };
                } else {
                    wxShareData = params;
                }
                app.wxShare(wxShareData);
            },
            // get vue vm
            getVm: function(name) {
                if (typeof name == "string") {
                    name = "js/" + name;
                    return seajs.Module.get(require.resolve(name)) && seajs.Module.get(require.resolve(name)).exports && seajs.Module.get(require.resolve(name)).exports.vm;
                } else {
                    return null;
                }
            },
            setPageData: function(pageName, data) {
                var curData = this.pageData[pageName] ? this.pageData[pageName] : {};
                // console.log("setPageData",data);
                for (var i in data) {
                    //console.log("i", i, data[i]);
                    curData[i] = data[i];
                }
                this.pageData[pageName] = curData;
            },
            getPageData: function(pageName, key) {
                var curData = this.pageData[pageName];
                if (key) {
                    return curData ? curData[key] : null;
                } else {
                    return curData;
                }
            },
            area: function(_this) {
                app.getScript("plug/area.js", function() {
                    $(_this).attr("domain", app.params.apiDomain);
                    $(_this).area();
                });
            },
            areaForbank: function(_this) {
                app.getScript("plug/areaForbank.js", function() {
                    $(_this).attr("domain", app.params.apiDomain);
                    $(_this).area();
                });
            },
            pay: function(order_sn, type) {
                var payurl = app.params.apiDomain + "apiv2/pay/run/?order_sn=" + order_sn;
                if (type) {
                    payurl += "&paytype=" + type;
                }
                if (ua.match(/MicroMessenger/i) == "micromessenger") {
                    //判断是否是微信环境
                    //微信环境
                    wx.miniProgram.getEnv(function(res) {
                        if (res.miniprogram) {
                            wx.miniProgram.navigateTo({
                                url: "/pages/pay/index?order_sn=" + order_sn
                            });
                            return false;
                        }
                    });
                }
                window.location.href = payurl;
            }
        };
        $.extend(true, app, fun);
        return app;
    };
    module.exports = app;
});

'use strict';

define(function (require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function () {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    item: {},
                    publish_text: '确认提交',
                    is_publish: 0,
                    type: 'cash',
                    mounted: 0,
                    time_limit: 0,
                    store: {},
                    showLimitTimeTex: '设置可使用时间段',
                    uploadUrl: app.params.apiDomain + "apiv2/card/uploadimg"
                };
            },
            el: '#pageAddCard',
            created: function created() {
                this.fetchData();
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    this.appid = this.$route.params.appid;
                    this.getStore();
                },
                getStore: function getStore() {
                    var _this = this;
                    var userInfo = app.getUserInfo();
                    app.get("api/user/info", { fields: 'store' }, function (res) {
                        // alert(123);
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        _this.store = res.data.store;
                    });
                },
                set_time_limit: function set_time_limit(time_limit) {
                    this.time_limit = time_limit;
                },
                set_type: function set_type(type) {
                    this.type = type;
                },

                saveTime: function saveTime() {
                    // var data = $("#pageAddCard").find("#popup_time_limit").serializeArray();
                    var showText = "";
                    var data = {};
                    var time_limit = {};
                    data.type = $("[name='date_info_type']:checked").val();
                    if (data.type == "DATE_TYPE_FIX_TIME_RANGE") {
                        //固定日期
                        data.begin_timestamp = $("#begin_timestamp").val();
                        data.end_timestamp = $("#end_timestamp").val();
                        if (data.end_timestamp === "" || data.begin_timestamp === "") {
                            app.alert("请选择固定日期");
                            return;
                        }
                        showText += "有效期:" + data.begin_timestamp + "~" + data.end_timestamp;
                    } else {
                        data.fixed_begin_term = $("[name='fixed_begin_term']").val();
                        data.fixed_term = $("[name='fixed_term']").val();
                        showText += "有效期:领取后" + (data.fixed_begin_term > 0 ? data.fixed_begin_term : '当') + "天内生效,";
                        showText += "有效天数" + data.fixed_term + "天";
                    }

                    var type = $("[name='time_limit']:checked").val();

                    if (type == 1) {
                        time_limit.type = [];
                        showText += "。可用日期:";
                        var length = $("[name='time_limit_type']:checked").length;

                        if (length === 0) {
                            app.alert("请选择可用日期");
                            return;
                        }
                        $.each($("[name='time_limit_type']:checked"), function (i, time_limit_type) {
                            time_limit.type.push($(time_limit_type).val());
                            showText += $(time_limit_type).parent().text();
                        });
                        time_limit.begin_hour = $("#time_limit_begin_hour").val();
                        time_limit.end_hour = $("#time_limit_end_hour").val();
                        if (time_limit.begin_hour === "" || time_limit.end_hour === "") {
                            app.alert("请选择可用时间");
                            return;
                        }
                        showText += time_limit.begin_hour + "~" + time_limit.end_hour;
                    } else {
                        showText += "。可用时间段:全天";
                    }
                    this.showLimitTimeTex = showText;
                    this.time_limit = time_limit;
                    this.date_info = data;
                    app.hide_popup();
                },
                publish: function publish() {
                    var _this = this;
                    if (_this.is_publish === 1) {
                        return;
                    }
                    _this.is_publish = 1;
                    // this.showLimitTimeTex = showText;
                    // this.time_limit = time_limit;
                    // this.date_info = data;
                    var data = $("#pageAddCard").find("#addCardForm").serializeArray();
                    data.push({
                        name: "time_limit",
                        value: JSON.stringify(this.time_limit)
                    });
                    data.push({
                        name: "date_info",
                        value: JSON.stringify(this.date_info)
                    });
                    data.push({
                        name: "showLimitTimeText",
                        value: this.showLimitTimeTex
                    });
                    data.push({
                        name: "appid",
                        value: this.appid
                    });

                    // console.log(data);

                    app.post("apiv2/card/create_" + _this.type, data, function (res) {
                        _this.is_publish = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        app.setPageData("index", { reload: 1 });
                        app.alert("创建成功", function () {
                            _this.$router.go(-2);
                        });
                    });
                },
                show_popup_time_limit: function show_popup_time_limit() {
                    app.show_popup($("#popup_time_limit"));
                }
            },

            mounted: function mounted() {
                // console.log("123");
                if (this.mounted == 1) {
                    return;
                }

                app.lCalendar("end_timestamp");
                app.lCalendar("begin_timestamp");
                app.lCalendar("time_limit_begin_hour");
                app.lCalendar("time_limit_end_hour");
                this.mounted = 1;
            }

        }).$mount('#app');
    };
    module.exports = controller;
});

'use strict';

define(function (require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function () {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    item: {},
                    publish_text: '确认提交',
                    is_publish: 0,
                    type: 'member_card',
                    mounted: 0,
                    store: {},
                    cardInfo: {
                        base_info: {}
                    },
                    id: 0,
                    card_id: 0,
                    uploadUrl: app.params.apiDomain + "apiv2/card/uploadimg"
                };
            },
            el: '#pageAddMemberCard',
            created: function created() {
                this.fetchData();
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    this.appid = this.$route.params.appid;
                    this.id = this.$route.params.id;
                    // console.log(this.id);
                    if (this.id > 0) {
                        this.getCardInfo();
                    }
                    this.getStore();
                },
                getCardInfo: function getCardInfo() {
                    var _this = this;
                    var userInfo = app.getUserInfo();
                    app.get("apiv2/wx-card/find", { id: this.id }, function (res) {
                        // alert(123);
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        _this.card_id = res.data.cardId;
                        _this.appid = res.data.appid;
                        _this.cardInfo = res.data.config;
                    });
                },

                getStore: function getStore() {
                    var _this = this;
                    var userInfo = app.getUserInfo();
                    app.get("api/user/info", { fields: 'store' }, function (res) {
                        // alert(123);
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        _this.store = res.data.store;
                    });
                },

                publish: function publish() {
                    var _this = this;
                    if (_this.is_publish === 1) {
                        return;
                    }

                    _this.is_publish = 1;
                    // this.showLimitTimeTex = showText;
                    // this.time_limit = time_limit;
                    // this.date_info = data;
                    var data = $("#pageAddMemberCard").find("#addCardForm").serializeArray();

                    data.push({
                        name: "appid",
                        value: this.appid
                    });
                    data.push({
                        name: "card_id",
                        value: this.card_id
                    });

                    // console.log(data);

                    app.post("apiv2/card/add", data, function (res) {
                        _this.is_publish = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        app.setPageData("memberCard", { reload: 1 });

                        app.alert("创建成功", function () {
                            _this.$router.go(-2);
                        });
                    });
                }

            },

            mounted: function mounted() {

                if (this.mounted == 1) {
                    return;
                }
                var _this = this;
                app.upload("#uploadBg", function () {
                    window.photo.uploadUrl = _this.uploadUrl;
                });

                this.mounted = 1;
            }

        }).$mount('#app');
    };
    module.exports = controller;
});

'use strict';

define(function (require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function () {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    cardInfo: {},
                    store: {},
                    loading: 0,
                    cardQrcodeInfo: {},
                    downUrl: ''

                };
            },
            el: '#pageCardDetail',
            created: function created() {
                this.fetchData();
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;

                    this.getInfo();
                },
                getCardQrcode: function getCardQrcode() {
                    //如果是微信打开卡包
                    var user_info = app.getUserInfo();
                    this.p_user_id = user_info.user_id;
                    this.shareUrl = window.location.origin + "/apps/wx-card/#/opencard/" + this.card_id + "/" + user_info.user_id;
                    this.show_qrcode_url = app.params.apiDomain + "/api/index/urlQRcode?url=" + encodeURIComponent(this.shareUrl);
                    this.downUrl = app.params.apiDomain + "/apiv2/card/download?url=" + encodeURIComponent(this.show_qrcode_url);
                },

                setWxShare: function setWxShare() {
                    if (!app.isWeiXin()) {
                        return;
                    }
                    var that = this;
                    var wxShareData = {
                        title: "[" + that.cardInfo.config.base_info.brand_name + "]" + that.cardInfo.base_info.title, // 分享标题
                        imgUrl: that.store.logo, // 分享图标
                        desc: "您的好友分享了一张卡券,快来领取吧",
                        url: this.shareUrl
                    };
                    app.wxShare(wxShareData);
                },
                //分享给好友
                share: function share() {
                    var text = '复制链接发给朋友：' + this.shareUrl;
                    if (app.isWeiXin()) {
                        text = "请点击微信右上角分享给好友";
                    }
                    app.confirm({
                        text: text
                    });
                },
                getInfo: function getInfo() {
                    var that = this;
                    if (that.loading == 1) {
                        return;
                    }
                    that.loading = 1;

                    var user_info = app.getUserInfo();
                    // app.get("api/user/info", {user_id:user_info.user_id,fields:'store'},function(res){
                    //     that.store = res.data.store;
                    // });
                    app.get("apiv2/wx_card/find", {
                        id: this.$route.params.id

                    }, function (res) {
                        that.loading = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        that.card_id = res.data.cardId;
                        that.cardInfo = res.data;
                        that.store = res.data.store;
                        that.getCardQrcode();
                        that.setWxShare();
                    });
                }
            }

        }).$mount('#app');
    };
    module.exports = controller;
});

'use strict';

define(function (require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function () {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    list: {},
                    store: {},
                    loading: 0,
                    name: 'addCard'

                };
            },
            el: '#pageChooseAppid',
            created: function created() {
                this.fetchData();
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;

                    this.get_public_platform();

                    this.name = this.$route.params.type;
                },
                addWxApp: function addWxApp() {
                    app.confirm({
                        text: '请在微信访问：https://www.bestsmartbee.com/admin/addon-wx-config/auth'
                    });
                },
                get_public_platform: function get_public_platform() {
                    var that = this;
                    if (that.loading == 1) {
                        return;
                    }
                    that.loading = 1;

                    var user_info = app.getUserInfo();
                    app.get("api/wechat_tool/get_public_platform", { store_id: user_info.store_id }, function (res) {
                        that.list = res.data;
                    });
                }
            }

        }).$mount('#app');
    };
    module.exports = controller;
});

'use strict';

define(function (require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function () {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    items: [],
                    store: {},
                    nodata: 0,
                    loading: 0,
                    title: '',
                    commission_money: ''

                };
            },
            el: '#pageIndex',
            created: function created() {
                this.fetchData();
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    this.getList();
                },
                addCard: function addCard() {
                    app.show_popup($("#popup_choose_wx"));
                },

                pageShow: function pageShow() {
                    var reload = app.getPageData("index", "reload");
                    var that = this;
                    if (reload == 1) {
                        app.setPageData("index", { reload: 0 });
                        that.getList(1);
                    }
                },
                setCommission: function setCommission($event) {
                    console.log($event);
                    var _this = $($event.target);
                    var that = this;
                    var title = _this.attr("data-title");
                    that.title = title;
                    that.target = _this;
                    that.id = _this.attr("data-idx");
                    var commission_money = _this.attr("data-commission_money");
                    if (commission_money > 0) {
                        that.commission_money = commission_money;
                    }
                    app.show_popup("#popup_commission");
                },

                saveCommission: function saveCommission() {
                    var that = this;
                    app.get("apiv2/wx_card/add", {
                        id: that.id,
                        commission_money: $("#commission_money").val()
                    }, function (res) {
                        that.loading = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        $(that.target).text($("#commission_money").val() + "%");
                        app.hide_popup("#popup_commission");
                    });
                },
                // more:function(e){
                //   // console.log(_this);
                //   var _this = $(e.target);
                //   var that = this;
                //   var id = _this.attr("data-id");
                //   var appid = _this.attr("data-appid");
                //   var card_id = _this.attr("data-card_id");
                //   var params=[
                //     {
                //       'text':'修改',
                //       'methods':function(){
                //            app.colseHandle();
                //            that.$router.push({ name: 'addMemberCard', params: { id: id,appid:appid } });
                //       }
                //     },
                //     {
                //       'text':'删除',
                //       'methods':function(){
                //           app.colseHandle();
                //           that.delete(card_id,_this);

                //       }
                //     }
                //   ];
                //   app.handle(params);

                //      // _this.$router.push({ name: 'addMemberCard', params: { id: _this.cardInfo. } });
                //      // { name: 'addMemberCard', params: { id: cardInfo.id ,appid:0 }}
                // },

                deleteCard: function deleteCard(e) {
                    var _this = $(e.target);
                    var that = this;
                    var id = _this.attr("data-id");
                    var appid = _this.attr("data-appid");
                    var card_id = _this.attr("data-card_id");

                    app.confirm({
                        'text': '删除卡券后，该卡券对应已生成的领取用二维码、添加到卡包JS API均会失效。确认删除吗？',
                        'yes': function yes() {
                            app.get("apiv2/card/delete", { card_id: card_id }, function (res) {
                                if (res.code != 200) {
                                    app.alert(res.msg);
                                    return;
                                }
                                _this.parents(".item").hide();
                            });
                        }
                    });
                },
                getList: function getList(reload) {
                    var that = this;

                    if (that.loading == 1) {
                        return;
                    }
                    that.loading = 1;

                    var user_info = app.getUserInfo();
                    app.get("api/user/info", { user_id: user_info.user_id, fields: 'store' }, function (res) {
                        that.store = res.data.store;
                    });
                    app.get("apiv2/wx_card/get", {
                        store_id: user_info.store_id,
                        limit: 50
                    }, function (res) {
                        that.loading = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        that.items = res.data.list;
                        if (that.items.length === 0) {
                            that.nodata = 1;
                        } else {
                            that.nodata = 0;
                        }
                    });
                }
            }

        }).$mount('#app');
    };
    module.exports = controller;
});

'use strict';

define(function (require) {
    var PuthinkApp = require('app');
    //vue 组件
    // require('js/component');
    //zach
    //配置文件
    var params = {
        apiDomain: seajs.data.apiDomain ? seajs.data.apiDomain : 'https://www.bestsmartbee.com/', //接口域名 不带"/"
        domain: '', //网站域名  不带"/",
        appname: seajs.data.appname,
        debug: seajs.data.debug ? seajs.data.debug : false,
        versions: seajs.data.versions ? seajs.data.versions : '6.8',
        userVersions: seajs.data.userVersions ? seajs.data.userVersions : '6.9'
    };

    //app 实例之后 ， 只执行一次
    PuthinkApp.afterInit = function () {
        var _hmt = _hmt || [];
    };

    //页面显示时引用，每次都会执行
    PuthinkApp.pageShow = function (params) {
        var name = params.name;
        // console.log();
    };

    //实例化app
    window.app = new PuthinkApp(params);
    app.login(function () {
        app.init();
    });
});

"use strict";

define(function (require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function () {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    items: [],
                    memberCardDetail: {
                        new_user: 0,
                        total_user: 0,
                        view_user: 0
                    },
                    store: {},
                    loading: 0,
                    nodata: 0,
                    showAddMemberCard: 0

                };
            },
            el: '#pageMemberCard',
            created: function created() {
                this.fetchData();
            },

            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    this.getList();
                },
                addCard: function addCard() {
                    app.show_popup($("#popup_choose_wx"));
                },
                pageShow: function pageShow() {
                    var that = this;
                    var reload = app.getPageData("memberCard", "reload");
                    if (reload == 1) {
                        app.setPageData("memberCard", { reload: 0 });
                        that.getList();
                    }
                },

                more: function more(e) {
                    // console.log(_this);
                    var _this = $(e.target);
                    var that = this;
                    var id = _this.attr("data-id");
                    var appid = _this.attr("data-appid");
                    var card_id = _this.attr("data-card_id");
                    var params = [{
                        'text': '充值/积分/等级',
                        'methods': function methods() {
                            app.colseHandle();
                            var user_info = app.getUserInfo();
                            window.location.href = app.params.apiDomain + "mall-admin/mall_promotion/index?from=webapp&from_wx_app=1&view=1&token=" + user_info.token;
                        }
                    }, {
                        'text': '修改',
                        'methods': function methods() {
                            app.colseHandle();
                            that.$router.push({ name: 'addMemberCard', params: { id: id, appid: appid } });
                        }
                    }, {
                        'text': '删除',
                        'methods': function methods() {
                            that.delete(card_id, _this);
                        }
                    }];
                    app.handle(params);

                    // _this.$router.push({ name: 'addMemberCard', params: { id: _this.cardInfo. } });
                    // { name: 'addMemberCard', params: { id: cardInfo.id ,appid:0 }}
                },
                delete: function _delete(card_id, _this) {
                    var that = this;
                    app.confirm({
                        'text': '删除卡券后，该卡券对应已生成的领取用二维码、添加到卡包JS API均会失效。确认删除吗？',
                        'yes': function yes() {
                            app.get("apiv2/card/delete", { card_id: card_id }, function (res) {
                                if (res.code != 200) {
                                    app.alert(res.msg);
                                    return;
                                }
                                _this.parents(".item").hide();
                                that.showAddMemberCard = 1;
                            });
                        }
                    });
                },

                getMemberCarddetail: function getMemberCarddetail() {
                    var memberCardDetail = {};
                    for (var i in this.items) {
                        var card_id = this.items[i].cardId;
                        var that = this;
                        app.get("apiv2/card/getMemberCarddetail", { card_id: card_id }, function (res) {
                            if (res.code == 200) {
                                memberCardDetail = res.data;
                                // console.log(memberCardDetail);
                                that.memberCardDetail = memberCardDetail;
                            }
                        });
                    }
                    // var items = that.items ;
                    //  that.items =[];
                    // console.log(memberCardDetail);

                },

                getList: function getList() {
                    var that = this;
                    if (that.loading == 1) {
                        return;
                    }
                    that.loading = 1;

                    var user_info = app.getUserInfo();
                    app.get("api/user/info", { user_id: user_info.user_id, fields: 'store' }, function (res) {
                        that.store = res.data.store;
                    });
                    app.get("apiv2/wx_card/get", {
                        store_id: user_info.store_id,
                        type: 'member_card',
                        limit: 50
                    }, function (res) {
                        that.loading = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }

                        if (!res.data.list.length) {
                            that.showAddMemberCard = 1;
                        }
                        that.items = res.data.list;
                        that.getMemberCarddetail();
                        if (that.items.length === 0) {
                            that.nodata = 1;
                        } else {
                            that.nodata = 0;
                        }
                    });
                }
            }

        }).$mount('#app');
    };

    module.exports = controller;
});

'use strict';

define(function (require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function () {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    items: [],
                    store: {},
                    loading: 0,
                    title: '',
                    page: 1,
                    lastpage: 0,
                    commission_money: '',
                    keyword: ''

                };
            },
            el: '#pageMemberList',
            created: function created() {
                this.fetchData();
            },
            mounted: function mounted() {
                // console.log("123");
                if (this.mounted == 1) {
                    return;
                }

                var that = this;
                app.pager("#pageMemberList", function () {
                    that.getList();
                });
                this.mounted = 1;
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    this.getList();
                },

                pageShow: function pageShow() {},
                search: function search(event) {
                    this.keyword = $("#keyword").val();

                    this.getList(1);
                },

                getList: function getList(reload) {
                    var that = this;
                    if (reload == 1) {
                        that.loading = 0;
                        that.lastpage = 0;
                        that.items = [];
                        that.page = 1;
                    }
                    if (that.loading == 1 || that.lastpage == 1) {
                        return;
                    }

                    that.loading = 1;

                    app.get("apiv2/wx_card_user/get", {
                        card_id: that.$route.params.card_id,
                        keyword: that.keyword,
                        limit: 50,
                        page: that.page
                    }, function (res) {
                        that.loading = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        if (res.data.list.length === 0) {
                            that.lastpage = 1;
                        }
                        that.page++;
                        that.items = that.items.concat(res.data.list);
                    });
                }
            }

        }).$mount('#app');
    };
    module.exports = controller;
});

'use strict';

define(function (require, exports, module) {
  var router = require("router");
  //var app = require("app");
  var controller = {};
  controller.vue = function () {
    controller.vm = new Vue({
      router: router,
      data: function data() {
        return {
          cardInfo: {},
          store: {},
          loading: 0,
          cardQrcodeInfo: {},
          downUrl: ''

        };
      },
      el: '#pageOpencard',
      created: function created() {
        this.fetchData();
      },
      methods: {
        fetchData: function fetchData() {
          var _this = this;
          if (app.isWeiXin()) {
            this.openCard();
          } else {
            this.$router.push({ name: 'cardDetail', params: { id: this.$route.params.id } });
          }
        },
        // 保存卡券到数库 
        saveCard: function saveCard(code) {
          var user_info = app.getUserInfo();
          app.post("mall/card/saveForWx", {
            user_id: user_info.user_id,
            p_user_id: this.$route.params.p_user_id,
            cardId: this.$route.params.id,
            code: code,
            store_id: user_info.store_id,
            shop_id: 0

          }, function (res) {
            if (res.code != 200) {
              app.alert(res.msg);
              return;
            }
            app.alert("领取成功", function () {
              app.wx.closeWindow();
            });
          });
        },
        //微信打开卡包
        openCard: function openCard() {
          var user_info = app.getUserInfo();
          var outer_str = this.$route.params.p_user_id + "_" + user_info.user_id;
          var that = this;
          var card_id = this.$route.params.id;
          app.showLoad();
          app.get("apiv2/card/openCard", {
            card_id: card_id,
            p_user_id: this.$route.params.p_user_id
          }, function (res) {
            if (res.code != 200) {
              if (res.code == 3) {
                window.location.href = app.params.apiDomain + "/apiv2/scene/bindWxCard?id=" + card_id;
                return;
              }
              app.alert(res.msg);
              return;
            }
            var data = res.data;
            app.wxJs(function (wx) {
              app.showLoad();

              wx.addCard({
                cardList: [{
                  cardId: data.card_id,
                  cardExt: '{"code": "' + data.code + '","outer_str":"' + outer_str + '", "nonce_str":"' + data.nonce_str + '", "timestamp": "' + data.timestamp + '", "signature":"' + data.signature + '"}'
                }],
                success: function success(res) {
                  that.saveCard(data.code);
                },
                cancel: function cancel(res) {
                  wx.closeWindow();
                }
              });
            });
          });
        }

      }

    }).$mount('#app');
  };
  module.exports = controller;
});

'use strict';

define(function (require, exports, module) {
    var Router = new VueRouter({
        routes: [{
            path: '/',
            name: 'index',
            page: 'cache',
            title: '微信卡券'
        }, {
            path: '/addCard/:appid/:id',
            name: 'addCard',
            title: '创建卡券'
        }, {
            path: '/cardDetail/:id',
            name: 'cardDetail'
        }, {
            path: '/opencard/:id/:p_user_id',
            name: 'opencard',
            title: '开卡'
        }, {
            path: '/chooseAppid/:type',
            page: 'cache',
            name: 'chooseAppid',
            title: '选择公众号'

        }, {
            path: '/memberCard',
            name: 'memberCard',
            page: 'cache',
            title: '会员卡'
        }, {
            path: '/addMemberCard/:appid/:id',
            name: 'addMemberCard',
            title: '创建会员卡'
        }, {
            path: '/memberList/:card_id',
            name: 'memberList',
            title: '会员列表'
        }]
    });
    module.exports = Router;
});

"use strict";

define("./js/addCard", [ "router" ], function(require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function() {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    item: {},
                    publish_text: "确认提交",
                    is_publish: 0,
                    type: "cash",
                    mounted: 0,
                    time_limit: 0,
                    store: {},
                    showLimitTimeTex: "设置可使用时间段",
                    uploadUrl: app.params.apiDomain + "apiv2/card/uploadimg"
                };
            },
            el: "#pageAddCard",
            created: function created() {
                this.fetchData();
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    this.appid = this.$route.params.appid;
                    this.getStore();
                },
                getStore: function getStore() {
                    var _this = this;
                    var userInfo = app.getUserInfo();
                    app.get("api/user/info", {
                        fields: "store"
                    }, function(res) {
                        // alert(123);
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        _this.store = res.data.store;
                    });
                },
                set_time_limit: function set_time_limit(time_limit) {
                    this.time_limit = time_limit;
                },
                set_type: function set_type(type) {
                    this.type = type;
                },
                saveTime: function saveTime() {
                    // var data = $("#pageAddCard").find("#popup_time_limit").serializeArray();
                    var showText = "";
                    var data = {};
                    var time_limit = {};
                    data.type = $("[name='date_info_type']:checked").val();
                    if (data.type == "DATE_TYPE_FIX_TIME_RANGE") {
                        //固定日期
                        data.begin_timestamp = $("#begin_timestamp").val();
                        data.end_timestamp = $("#end_timestamp").val();
                        if (data.end_timestamp === "" || data.begin_timestamp === "") {
                            app.alert("请选择固定日期");
                            return;
                        }
                        showText += "有效期:" + data.begin_timestamp + "~" + data.end_timestamp;
                    } else {
                        data.fixed_begin_term = $("[name='fixed_begin_term']").val();
                        data.fixed_term = $("[name='fixed_term']").val();
                        showText += "有效期:领取后" + (data.fixed_begin_term > 0 ? data.fixed_begin_term : "当") + "天内生效,";
                        showText += "有效天数" + data.fixed_term + "天";
                    }
                    var type = $("[name='time_limit']:checked").val();
                    if (type == 1) {
                        time_limit.type = [];
                        showText += "。可用日期:";
                        var length = $("[name='time_limit_type']:checked").length;
                        if (length === 0) {
                            app.alert("请选择可用日期");
                            return;
                        }
                        $.each($("[name='time_limit_type']:checked"), function(i, time_limit_type) {
                            time_limit.type.push($(time_limit_type).val());
                            showText += $(time_limit_type).parent().text();
                        });
                        time_limit.begin_hour = $("#time_limit_begin_hour").val();
                        time_limit.end_hour = $("#time_limit_end_hour").val();
                        if (time_limit.begin_hour === "" || time_limit.end_hour === "") {
                            app.alert("请选择可用时间");
                            return;
                        }
                        showText += time_limit.begin_hour + "~" + time_limit.end_hour;
                    } else {
                        showText += "。可用时间段:全天";
                    }
                    this.showLimitTimeTex = showText;
                    this.time_limit = time_limit;
                    this.date_info = data;
                    app.hide_popup();
                },
                publish: function publish() {
                    var _this = this;
                    if (_this.is_publish === 1) {
                        return;
                    }
                    _this.is_publish = 1;
                    // this.showLimitTimeTex = showText;
                    // this.time_limit = time_limit;
                    // this.date_info = data;
                    var data = $("#pageAddCard").find("#addCardForm").serializeArray();
                    data.push({
                        name: "time_limit",
                        value: JSON.stringify(this.time_limit)
                    });
                    data.push({
                        name: "date_info",
                        value: JSON.stringify(this.date_info)
                    });
                    data.push({
                        name: "showLimitTimeText",
                        value: this.showLimitTimeTex
                    });
                    data.push({
                        name: "appid",
                        value: this.appid
                    });
                    // console.log(data);
                    app.post("apiv2/card/create_" + _this.type, data, function(res) {
                        _this.is_publish = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        app.setPageData("index", {
                            reload: 1
                        });
                        app.alert("创建成功", function() {
                            _this.$router.go(-2);
                        });
                    });
                },
                show_popup_time_limit: function show_popup_time_limit() {
                    app.show_popup($("#popup_time_limit"));
                }
            },
            mounted: function mounted() {
                // console.log("123");
                if (this.mounted == 1) {
                    return;
                }
                app.lCalendar("end_timestamp");
                app.lCalendar("begin_timestamp");
                app.lCalendar("time_limit_begin_hour");
                app.lCalendar("time_limit_end_hour");
                this.mounted = 1;
            }
        }).$mount("#app");
    };
    module.exports = controller;
});

"use strict";

define("./js/addMemberCard", [ "router" ], function(require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function() {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    item: {},
                    publish_text: "确认提交",
                    is_publish: 0,
                    type: "member_card",
                    mounted: 0,
                    store: {},
                    cardInfo: {
                        base_info: {}
                    },
                    id: 0,
                    card_id: 0,
                    uploadUrl: app.params.apiDomain + "apiv2/card/uploadimg"
                };
            },
            el: "#pageAddMemberCard",
            created: function created() {
                this.fetchData();
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    this.appid = this.$route.params.appid;
                    this.id = this.$route.params.id;
                    // console.log(this.id);
                    if (this.id > 0) {
                        this.getCardInfo();
                    }
                    this.getStore();
                },
                getCardInfo: function getCardInfo() {
                    var _this = this;
                    var userInfo = app.getUserInfo();
                    app.get("apiv2/wx-card/find", {
                        id: this.id
                    }, function(res) {
                        // alert(123);
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        _this.card_id = res.data.cardId;
                        _this.appid = res.data.appid;
                        _this.cardInfo = res.data.config;
                    });
                },
                getStore: function getStore() {
                    var _this = this;
                    var userInfo = app.getUserInfo();
                    app.get("api/user/info", {
                        fields: "store"
                    }, function(res) {
                        // alert(123);
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        _this.store = res.data.store;
                    });
                },
                publish: function publish() {
                    var _this = this;
                    if (_this.is_publish === 1) {
                        return;
                    }
                    _this.is_publish = 1;
                    // this.showLimitTimeTex = showText;
                    // this.time_limit = time_limit;
                    // this.date_info = data;
                    var data = $("#pageAddMemberCard").find("#addCardForm").serializeArray();
                    data.push({
                        name: "appid",
                        value: this.appid
                    });
                    data.push({
                        name: "card_id",
                        value: this.card_id
                    });
                    // console.log(data);
                    app.post("apiv2/card/add", data, function(res) {
                        _this.is_publish = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        app.setPageData("memberCard", {
                            reload: 1
                        });
                        app.alert("创建成功", function() {
                            _this.$router.go(-2);
                        });
                    });
                }
            },
            mounted: function mounted() {
                if (this.mounted == 1) {
                    return;
                }
                var _this = this;
                app.upload("#uploadBg", function() {
                    window.photo.uploadUrl = _this.uploadUrl;
                });
                this.mounted = 1;
            }
        }).$mount("#app");
    };
    module.exports = controller;
});

"use strict";

define("./js/cardDetail", [ "router" ], function(require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function() {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    cardInfo: {},
                    store: {},
                    loading: 0,
                    cardQrcodeInfo: {},
                    downUrl: ""
                };
            },
            el: "#pageCardDetail",
            created: function created() {
                this.fetchData();
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    this.getInfo();
                },
                getCardQrcode: function getCardQrcode() {
                    //如果是微信打开卡包
                    var user_info = app.getUserInfo();
                    this.p_user_id = user_info.user_id;
                    this.shareUrl = window.location.origin + "/apps/wx-card/#/opencard/" + this.card_id + "/" + user_info.user_id;
                    this.show_qrcode_url = app.params.apiDomain + "/api/index/urlQRcode?url=" + encodeURIComponent(this.shareUrl);
                    this.downUrl = app.params.apiDomain + "/apiv2/card/download?url=" + encodeURIComponent(this.show_qrcode_url);
                },
                setWxShare: function setWxShare() {
                    if (!app.isWeiXin()) {
                        return;
                    }
                    var that = this;
                    var wxShareData = {
                        title: "[" + that.cardInfo.config.base_info.brand_name + "]" + that.cardInfo.base_info.title,
                        // 分享标题
                        imgUrl: that.store.logo,
                        // 分享图标
                        desc: "您的好友分享了一张卡券,快来领取吧",
                        url: this.shareUrl
                    };
                    app.wxShare(wxShareData);
                },
                //分享给好友
                share: function share() {
                    var text = "复制链接发给朋友：" + this.shareUrl;
                    if (app.isWeiXin()) {
                        text = "请点击微信右上角分享给好友";
                    }
                    app.confirm({
                        text: text
                    });
                },
                getInfo: function getInfo() {
                    var that = this;
                    if (that.loading == 1) {
                        return;
                    }
                    that.loading = 1;
                    var user_info = app.getUserInfo();
                    // app.get("api/user/info", {user_id:user_info.user_id,fields:'store'},function(res){
                    //     that.store = res.data.store;
                    // });
                    app.get("apiv2/wx_card/find", {
                        id: this.$route.params.id
                    }, function(res) {
                        that.loading = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        that.card_id = res.data.cardId;
                        that.cardInfo = res.data;
                        that.store = res.data.store;
                        that.getCardQrcode();
                        that.setWxShare();
                    });
                }
            }
        }).$mount("#app");
    };
    module.exports = controller;
});

"use strict";

define("./js/chooseAppid", [ "router" ], function(require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function() {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    list: {},
                    store: {},
                    loading: 0,
                    name: "addCard"
                };
            },
            el: "#pageChooseAppid",
            created: function created() {
                this.fetchData();
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    this.get_public_platform();
                    this.name = this.$route.params.type;
                },
                addWxApp: function addWxApp() {
                    app.confirm({
                        text: "请在微信访问：https://www.bestsmartbee.com/admin/addon-wx-config/auth"
                    });
                },
                get_public_platform: function get_public_platform() {
                    var that = this;
                    if (that.loading == 1) {
                        return;
                    }
                    that.loading = 1;
                    var user_info = app.getUserInfo();
                    app.get("api/wechat_tool/get_public_platform", {
                        store_id: user_info.store_id
                    }, function(res) {
                        that.list = res.data;
                    });
                }
            }
        }).$mount("#app");
    };
    module.exports = controller;
});

"use strict";

define("./js/index", [ "router" ], function(require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function() {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    items: [],
                    store: {},
                    nodata: 0,
                    loading: 0,
                    title: "",
                    commission_money: ""
                };
            },
            el: "#pageIndex",
            created: function created() {
                this.fetchData();
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    this.getList();
                },
                addCard: function addCard() {
                    app.show_popup($("#popup_choose_wx"));
                },
                pageShow: function pageShow() {
                    var reload = app.getPageData("index", "reload");
                    var that = this;
                    if (reload == 1) {
                        app.setPageData("index", {
                            reload: 0
                        });
                        that.getList(1);
                    }
                },
                setCommission: function setCommission($event) {
                    console.log($event);
                    var _this = $($event.target);
                    var that = this;
                    var title = _this.attr("data-title");
                    that.title = title;
                    that.target = _this;
                    that.id = _this.attr("data-idx");
                    var commission_money = _this.attr("data-commission_money");
                    if (commission_money > 0) {
                        that.commission_money = commission_money;
                    }
                    app.show_popup("#popup_commission");
                },
                saveCommission: function saveCommission() {
                    var that = this;
                    app.get("apiv2/wx_card/add", {
                        id: that.id,
                        commission_money: $("#commission_money").val()
                    }, function(res) {
                        that.loading = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        $(that.target).text($("#commission_money").val() + "%");
                        app.hide_popup("#popup_commission");
                    });
                },
                // more:function(e){
                //   // console.log(_this);
                //   var _this = $(e.target);
                //   var that = this;
                //   var id = _this.attr("data-id");
                //   var appid = _this.attr("data-appid");
                //   var card_id = _this.attr("data-card_id");
                //   var params=[
                //     {
                //       'text':'修改',
                //       'methods':function(){
                //            app.colseHandle();
                //            that.$router.push({ name: 'addMemberCard', params: { id: id,appid:appid } });
                //       }
                //     },
                //     {
                //       'text':'删除',
                //       'methods':function(){
                //           app.colseHandle();
                //           that.delete(card_id,_this);
                //       }
                //     }
                //   ];
                //   app.handle(params);
                //      // _this.$router.push({ name: 'addMemberCard', params: { id: _this.cardInfo. } });
                //      // { name: 'addMemberCard', params: { id: cardInfo.id ,appid:0 }}
                // },
                deleteCard: function deleteCard(e) {
                    var _this = $(e.target);
                    var that = this;
                    var id = _this.attr("data-id");
                    var appid = _this.attr("data-appid");
                    var card_id = _this.attr("data-card_id");
                    app.confirm({
                        text: "删除卡券后，该卡券对应已生成的领取用二维码、添加到卡包JS API均会失效。确认删除吗？",
                        yes: function yes() {
                            app.get("apiv2/card/delete", {
                                card_id: card_id
                            }, function(res) {
                                if (res.code != 200) {
                                    app.alert(res.msg);
                                    return;
                                }
                                _this.parents(".item").hide();
                            });
                        }
                    });
                },
                getList: function getList(reload) {
                    var that = this;
                    if (that.loading == 1) {
                        return;
                    }
                    that.loading = 1;
                    var user_info = app.getUserInfo();
                    app.get("api/user/info", {
                        user_id: user_info.user_id,
                        fields: "store"
                    }, function(res) {
                        that.store = res.data.store;
                    });
                    app.get("apiv2/wx_card/get", {
                        store_id: user_info.store_id,
                        limit: 50
                    }, function(res) {
                        that.loading = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        that.items = res.data.list;
                        if (that.items.length === 0) {
                            that.nodata = 1;
                        } else {
                            that.nodata = 0;
                        }
                    });
                }
            }
        }).$mount("#app");
    };
    module.exports = controller;
});

"use strict";

define("./js/main", [ "app" ], function(require) {
    var PuthinkApp = require("app");
    //vue 组件
    // require('js/component');
    //zach
    //配置文件
    var params = {
        apiDomain: seajs.data.apiDomain ? seajs.data.apiDomain : "https://www.bestsmartbee.com/",
        //接口域名 不带"/"
        domain: "",
        //网站域名  不带"/",
        appname: seajs.data.appname,
        debug: seajs.data.debug ? seajs.data.debug : false,
        versions: seajs.data.versions ? seajs.data.versions : "6.8",
        userVersions: seajs.data.userVersions ? seajs.data.userVersions : "6.9"
    };
    //app 实例之后 ， 只执行一次
    PuthinkApp.afterInit = function() {
        var _hmt = _hmt || [];
    };
    //页面显示时引用，每次都会执行
    PuthinkApp.pageShow = function(params) {
        var name = params.name;
    };
    //实例化app
    window.app = new PuthinkApp(params);
    app.login(function() {
        app.init();
    });
});

"use strict";

define("./js/memberCard", [ "router" ], function(require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function() {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    items: [],
                    memberCardDetail: {
                        new_user: 0,
                        total_user: 0,
                        view_user: 0
                    },
                    store: {},
                    loading: 0,
                    nodata: 0,
                    showAddMemberCard: 0
                };
            },
            el: "#pageMemberCard",
            created: function created() {
                this.fetchData();
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    this.getList();
                },
                addCard: function addCard() {
                    app.show_popup($("#popup_choose_wx"));
                },
                pageShow: function pageShow() {
                    var that = this;
                    var reload = app.getPageData("memberCard", "reload");
                    if (reload == 1) {
                        app.setPageData("memberCard", {
                            reload: 0
                        });
                        that.getList();
                    }
                },
                more: function more(e) {
                    // console.log(_this);
                    var _this = $(e.target);
                    var that = this;
                    var id = _this.attr("data-id");
                    var appid = _this.attr("data-appid");
                    var card_id = _this.attr("data-card_id");
                    var params = [ {
                        text: "充值/积分/等级",
                        methods: function methods() {
                            app.colseHandle();
                            var user_info = app.getUserInfo();
                            window.location.href = app.params.apiDomain + "mall-admin/mall_promotion/index?from=webapp&from_wx_app=1&view=1&token=" + user_info.token;
                        }
                    }, {
                        text: "修改",
                        methods: function methods() {
                            app.colseHandle();
                            that.$router.push({
                                name: "addMemberCard",
                                params: {
                                    id: id,
                                    appid: appid
                                }
                            });
                        }
                    }, {
                        text: "删除",
                        methods: function methods() {
                            that.delete(card_id, _this);
                        }
                    } ];
                    app.handle(params);
                },
                "delete": function _delete(card_id, _this) {
                    var that = this;
                    app.confirm({
                        text: "删除卡券后，该卡券对应已生成的领取用二维码、添加到卡包JS API均会失效。确认删除吗？",
                        yes: function yes() {
                            app.get("apiv2/card/delete", {
                                card_id: card_id
                            }, function(res) {
                                if (res.code != 200) {
                                    app.alert(res.msg);
                                    return;
                                }
                                _this.parents(".item").hide();
                                that.showAddMemberCard = 1;
                            });
                        }
                    });
                },
                getMemberCarddetail: function getMemberCarddetail() {
                    var memberCardDetail = {};
                    for (var i in this.items) {
                        var card_id = this.items[i].cardId;
                        var that = this;
                        app.get("apiv2/card/getMemberCarddetail", {
                            card_id: card_id
                        }, function(res) {
                            if (res.code == 200) {
                                memberCardDetail = res.data;
                                // console.log(memberCardDetail);
                                that.memberCardDetail = memberCardDetail;
                            }
                        });
                    }
                },
                getList: function getList() {
                    var that = this;
                    if (that.loading == 1) {
                        return;
                    }
                    that.loading = 1;
                    var user_info = app.getUserInfo();
                    app.get("api/user/info", {
                        user_id: user_info.user_id,
                        fields: "store"
                    }, function(res) {
                        that.store = res.data.store;
                    });
                    app.get("apiv2/wx_card/get", {
                        store_id: user_info.store_id,
                        type: "member_card",
                        limit: 50
                    }, function(res) {
                        that.loading = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        if (!res.data.list.length) {
                            that.showAddMemberCard = 1;
                        }
                        that.items = res.data.list;
                        that.getMemberCarddetail();
                        if (that.items.length === 0) {
                            that.nodata = 1;
                        } else {
                            that.nodata = 0;
                        }
                    });
                }
            }
        }).$mount("#app");
    };
    module.exports = controller;
});

"use strict";

define("./js/memberList", [ "router" ], function(require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function() {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    items: [],
                    store: {},
                    loading: 0,
                    title: "",
                    page: 1,
                    lastpage: 0,
                    commission_money: "",
                    keyword: ""
                };
            },
            el: "#pageMemberList",
            created: function created() {
                this.fetchData();
            },
            mounted: function mounted() {
                // console.log("123");
                if (this.mounted == 1) {
                    return;
                }
                var that = this;
                app.pager("#pageMemberList", function() {
                    that.getList();
                });
                this.mounted = 1;
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    this.getList();
                },
                pageShow: function pageShow() {},
                search: function search(event) {
                    this.keyword = $("#keyword").val();
                    this.getList(1);
                },
                getList: function getList(reload) {
                    var that = this;
                    if (reload == 1) {
                        that.loading = 0;
                        that.lastpage = 0;
                        that.items = [];
                        that.page = 1;
                    }
                    if (that.loading == 1 || that.lastpage == 1) {
                        return;
                    }
                    that.loading = 1;
                    app.get("apiv2/wx_card_user/get", {
                        card_id: that.$route.params.card_id,
                        keyword: that.keyword,
                        limit: 50,
                        page: that.page
                    }, function(res) {
                        that.loading = 0;
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        if (res.data.list.length === 0) {
                            that.lastpage = 1;
                        }
                        that.page++;
                        that.items = that.items.concat(res.data.list);
                    });
                }
            }
        }).$mount("#app");
    };
    module.exports = controller;
});

"use strict";

define("./js/opencard", [ "router" ], function(require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function() {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    cardInfo: {},
                    store: {},
                    loading: 0,
                    cardQrcodeInfo: {},
                    downUrl: ""
                };
            },
            el: "#pageOpencard",
            created: function created() {
                this.fetchData();
            },
            methods: {
                fetchData: function fetchData() {
                    var _this = this;
                    if (app.isWeiXin()) {
                        this.openCard();
                    } else {
                        this.$router.push({
                            name: "cardDetail",
                            params: {
                                id: this.$route.params.id
                            }
                        });
                    }
                },
                // 保存卡券到数库 
                saveCard: function saveCard(code) {
                    var user_info = app.getUserInfo();
                    app.post("mall/card/saveForWx", {
                        user_id: user_info.user_id,
                        p_user_id: this.$route.params.p_user_id,
                        cardId: this.$route.params.id,
                        code: code,
                        store_id: user_info.store_id,
                        shop_id: 0
                    }, function(res) {
                        if (res.code != 200) {
                            app.alert(res.msg);
                            return;
                        }
                        app.alert("领取成功", function() {
                            app.wx.closeWindow();
                        });
                    });
                },
                //微信打开卡包
                openCard: function openCard() {
                    var user_info = app.getUserInfo();
                    var outer_str = this.$route.params.p_user_id + "_" + user_info.user_id;
                    var that = this;
                    var card_id = this.$route.params.id;
                    app.showLoad();
                    app.get("apiv2/card/openCard", {
                        card_id: card_id,
                        p_user_id: this.$route.params.p_user_id
                    }, function(res) {
                        if (res.code != 200) {
                            if (res.code == 3) {
                                window.location.href = app.params.apiDomain + "/apiv2/scene/bindWxCard?id=" + card_id;
                                return;
                            }
                            app.alert(res.msg);
                            return;
                        }
                        var data = res.data;
                        app.wxJs(function(wx) {
                            app.showLoad();
                            wx.addCard({
                                cardList: [ {
                                    cardId: data.card_id,
                                    cardExt: '{"code": "' + data.code + '","outer_str":"' + outer_str + '", "nonce_str":"' + data.nonce_str + '", "timestamp": "' + data.timestamp + '", "signature":"' + data.signature + '"}'
                                } ],
                                success: function success(res) {
                                    that.saveCard(data.code);
                                },
                                cancel: function cancel(res) {
                                    wx.closeWindow();
                                }
                            });
                        });
                    });
                }
            }
        }).$mount("#app");
    };
    module.exports = controller;
});

"use strict";

define("./js/router", [], function(require, exports, module) {
    var Router = new VueRouter({
        routes: [ {
            path: "/",
            name: "index",
            page: "cache",
            title: "微信卡券"
        }, {
            path: "/addCard/:appid/:id",
            name: "addCard",
            title: "创建卡券"
        }, {
            path: "/cardDetail/:id",
            name: "cardDetail"
        }, {
            path: "/opencard/:id/:p_user_id",
            name: "opencard",
            title: "开卡"
        }, {
            path: "/chooseAppid/:type",
            page: "cache",
            name: "chooseAppid",
            title: "选择公众号"
        }, {
            path: "/memberCard",
            name: "memberCard",
            page: "cache",
            title: "会员卡"
        }, {
            path: "/addMemberCard/:appid/:id",
            name: "addMemberCard",
            title: "创建会员卡"
        }, {
            path: "/memberList/:card_id",
            name: "memberList",
            title: "会员列表"
        } ]
    });
    module.exports = Router;
});

define("./template_js/addCard", [], function(require, exports, module) {
    return '<div class="page-content">	 <div class="step">	 	 	 </div>	 <form id="addCardForm">	 	  <div class="list-li">	       		 <div style="text-align: center; padding-bottom: 10px">	       		 	<img style="    width: 70px;padding:10px 10px 0px 0px;" :src="store.logo">  					<div>  						<a class="color_5"  :href="\'/apps/shop_admin/?store_id=\'+store.store_id+\'#/merchantInfo\'">点击修改商户名称及logo </a>  					</div>	       		 </div>		       		  <div class="li"  >	            	<div class="li-input-text">商户名称</div>		            <div class="li-input">		              <input  maxlength="9" disabled :value=\'store.store_name\'></input>		            </div>		            <div class="clear"></div>	         	 </div> 	         	 <div class="li"  >	            	<div class="li-input-text">卡券名</div>		            <div class="li-input">		              <input  maxlength="9" placeholder=\'建议涵盖卡券属性、服务及金额\' value=\'\' name=\'title\'></input>		            </div>		            <div class="clear"></div>	         	 </div> 	         	  <div class="li"  >	            	<div class="li-input-text">卡券库存</div>		            <div class="li-input">		              <input  maxlength="9" type="number" placeholder=\'卡券库存的数量\' value=\'999999\' name=\'quantity\'></input>		            </div>		            <div class="clear"></div>	         	 </div> 	         	  <div class="li"  >	            	<div class="li-input-text">限领张数</div>		            <div class="li-input">		              <input  maxlength="2" type="number" placeholder=\'每人可领券的张数\' value=\'1\' name=\'get_limit\'></input>		            </div>		            <div class="clear"></div>	         	 </div> 	         	  <div class="li"  >	            	<div class="li-input-text">卡券类型</div>		            <div class="li-input">		                          <label v-on:click="set_type(\'cash\')"  ><input style="width:10px;vertical-align: middle;" type="radio" name="type"  checked> 满减</label>		                <label v-on:click="set_type(\'discount\')"  ><input style="width:10px;vertical-align: middle;" type="radio" name="type"  > 折扣 </label>		            </div>		            <div class="clear"></div>	         	 </div> 	         	 <div class="li"   v-if="type == \'discount\' ">	            	<div class="li-input-text">折扣</div>		            <div class="li-input">		              <input  maxlength="2" type="number" placeholder=\'填30就是七折\' value=\'\' name=\'discount\'></input>		            </div>		            <div class="clear"></div>	         	 </div> 	         	  <div class="li"   v-if="type == \'cash\' ">	            	<div class="li-input-text">满减</div>		            <div class="li-input">		               <div class="fl">满</div>		               <input  class="fl" style="width: 50px; text-align: center;" maxlength="4" type="number" placeholder=\'100\' value=\'\' name=\'least_cost\'></input>		              <div class="fl"> 减 </div>		              <input class="fl" style="width: 50px;text-align: center;" maxlength="4" type="number" placeholder=\'30\' value=\'\' name=\'reduce_cost\'></input>		            </div>		            <div class="clear"></div>	         	 </div> 	         	 <div class="li"  >	            	<div class="li-input-text">可用时间</div>		            <div class="li-input" v-on:click="show_popup_time_limit($event)"  >		            	 {{showLimitTimeTex}}		            </div>		            <div class="clear"></div>	         	</div> 	         	 	           <div class="li"  >	            	<div class="li-input-text">使用提醒</div>		            <div class="li-input">		              <input maxlength="16"  placeholder=\'卡券使用提醒\' value=\'到店使用时向服务员出示此券\' name=\'notice\'></input>		            </div>		            <div class="clear"></div>	         	</div> 	         	 <div class="li"  >	            	<div class="li-input-text">使用说明</div>		            <div class="li-input">		            	<textarea maxlength="1024"  placeholder=\'卡券使用说明\' name="description"></textarea>		             		            </div>		            <div class="clear"></div>	         	</div> 	         	       </div>           <div  v-if="is_publish == 1" class="btn w80 disable "   style="margin-left: 10%; margin-top: 20px; margin-bottom: 30px">确认创建卡券</div>       <div  v-if="is_publish == 0" class="btn w80" v-on:click="publish($event)"  style="margin-left: 10%; margin-top: 20px; margin-bottom: 30px">确认创建卡券</div>	 </div>	 </form><!-- 设置时间段 -->	 <form class="popup" id="popup_time_limit" style="background-color: #fff;">	 	 <div class="list-li">	       	 		       	 	 	       	 	<div class="li"  >	       	 		<div class="li-input-text">有效期</div>	            	 		            <div class="li-input">		            	<label><input style="width:10px;vertical-align: middle;" type="radio" name="date_info_type" value="DATE_TYPE_FIX_TIME_RANGE"> 固定日期</label>		            	<div class="clear"></div>		               <input placeholder="开始日期" id="begin_timestamp" class="fl" style="width: 90px;" data-type="date"   readonly    data-lcalendar="2018-01-1,2022-12-31" value=\'\' name=\'begin_timestamp\'></input>		              <div class="fl light"> 至 </div>		              <input placeholder="结束日期" class="fl"  id="end_timestamp" style="width: 90px;text-align: center; margin-left:5px"  data-type="date" readonly    data-lcalendar="2018-01-1,2022-12-31"  value=\'\' name=\'end_timestamp\'></input>		               <div class="clear"></div>		               <label><input style="width:10px;vertical-align: middle;" type="radio" name="date_info_type" value="DATE_TYPE_FIX_TERM" checked> 领取后</label>		            	<div class="clear"></div>		            	<select class="fl" name="fixed_begin_term" style="margin-top: 3px;">		            		<option value="0">当天</option>		            		<option  :value="n" v-for="n in 40">{{n}}天</option>		            		 		            	</select>		              <div class="fl light"> 生效，有效天数 </div>		              <select class="fl" name="fixed_term" style="margin-top: 3px;">		              	<option :value="n" v-for="n in 100" :selected="n==10?\'selected\':\'\'">{{n}}天</option>		              </select>		            </div>		            <div class="clear"></div>	         	 </div> 	         	 	         	  <div class="li"  >	            	<div class="li-input-text">可用时段</div>		            <div class="li-input"> 		               <label v-on:click="set_time_limit(0)"  ><input style="width:10px;vertical-align: middle;" type="radio" name="time_limit" value="0" checked> 全天</label>		                <label v-on:click="set_time_limit(1)"  ><input style="width:10px;vertical-align: middle;" type="radio" name="time_limit" value="1" > 部分时段 </label>		                 <div class="clear"></div>		                <div :class="time_limit==1?\'\':\'none\' ">		                 <div> 日期</div>		                <label><input style="width:10px;vertical-align: middle;" type="checkbox" name="time_limit_type" value="MONDAY"> 周一</label>		                <label><input style="width:10px;vertical-align: middle;" type="checkbox" name="time_limit_type" value="TUESDAY"> 周二 </label>		                 <label><input style="width:10px;vertical-align: middle;" type="checkbox" name="time_limit_type" value="WEDNESDAY"> 周三 </label>		                  <label><input style="width:10px;vertical-align: middle;" type="checkbox" name="time_limit_type" value="THURSDAY"> 周四 </label>		                   <label><input style="width:10px;vertical-align: middle;" type="checkbox" name="time_limit_type" value="FRIDAY"> 周五 </label>		                    <label><input style="width:10px;vertical-align: middle;" type="checkbox" name="time_limit_type" value="SATURDAY"> 周六 </label>		                     <label><input style="width:10px;vertical-align: middle;" type="checkbox" name="time_limit_type" value="SUNDAY"> 周日 </label>		                      <div class="clear"></div>	                       <div> 时间 </div>	                       <input placeholder="开始时间" id="time_limit_begin_hour" class="fl" style="width: 90px; "     readonly   data-type="time"    ></input>			              <div class="fl light"> 至 </div>			              <input placeholder="结束时间" class="fl"  id="time_limit_end_hour" style="width: 90px;text-align: center;"  readonly  data-type="time"  ></input>			          </div>			               <div class="clear"></div>		            </div>		            <div class="clear"></div>	         	 </div> 	         	         <div    class="btn w80" v-on:click="saveTime($event)"  style="margin-left: 10%; margin-top: 20px; margin-bottom: 30px">保存</div>	     </form>    <!-- 设置时间段 --></div>';
});

define("./template_js/addMemberCard", [], function(require, exports, module) {
    return '<div class="page-content">	 <div class="step">	 	 	 </div>	 <form id="addCardForm">	 	  <div class="list-li">	       		<div style="text-align: center; padding-bottom: 10px" v-if="id==0">	       		 	<img style="    width: 70px;padding:10px 10px 0px 0px;" :src="store.logo">  					<div>  						<a class="color_5"  :href="\'/apps/shop_admin/?store_id=\'+store.store_id+\'#/merchantInfo\'">点击修改商户名称及logo </a>  					</div>	       		 </div>		         	 <div class="li"  >	            	<div class="li-input-text">名称</div>		            <div class="li-input">		              <input  maxlength="9" placeholder=\'会员卡名称\' :value=\'cardInfo.base_info.title\' name=\'title\'></input>		            </div>		            <div class="clear"></div>	         	 </div> 	         	 <div class="li"  >	            	<div class="li-input-text">封面</div>		            <div class="li-input">		               <div class="" id="uploadBg" :url="uploadUrl" maxUpload="1"></div>		               <div class="light" v-if="id>0">如须更改封面，请重新上传</div>		            </div>		            <div class="clear"></div>	         	 </div> 	 			<div class="li"  >	            	<div class="li-input-text">居中按钮</div>		            <div class="li-input">		              <input  maxlength="9" placeholder=\'如：立即使用\' :value=\'cardInfo.base_info.center_title?cardInfo.base_info.center_title:"立即使用"\'  name=\'center_title\'></input>		            </div>		            <div class="clear"></div>	         	 </div> 	         	 <div class="li"  >	            	<div class="li-input-text">副标题</div>		            <div class="li-input">		              <input  maxlength="9" placeholder=\'如：使用会员卡下单有优惠哦\' :value=\'cardInfo.base_info.center_sub_title?cardInfo.base_info.center_sub_title:"使用会员卡下单有优惠哦"\' name=\'center_sub_title\'></input>		            </div>		            <div class="clear"></div>	         	 </div> 	         	 	         	  <div class="li"  v-if="!id">	            	<div class="li-input-text">卡券库存</div>		            <div class="li-input">		              <input  maxlength="9" type="number" placeholder=\'卡券库存的数量\'  value=\'999999\'  name=\'quantity\'></input>		            </div>		            <div class="clear"></div>	         	 </div> 	         	  <div class="li"  >	            	 	<div class="li-input-text">积分规则</div>		            <div class="li-input">		              <input  maxlength="120" type="text" placeholder=\'积分规则\' value=\'每消费1元增加1积分\' name=\'bonus_rules\'></input>		            </div>		           		            <div class="clear"></div>	         	 </div> 	           				   				  <div class="li hidden"  >	            	<div class="li-input-text">获取基本信息</div>		            <div class="li-input">		                          <label  ><input checked style="width:10px;vertical-align: middle;" value="1" type="radio" name="wx_activate"  > 是</label>		                <label  ><input style="width:10px;vertical-align: middle;" type="radio" value="0"  name="wx_activate"  > 否 </label> <span clas="light">(领取会员卡时，需要填写手机号)</span>		            </div>		            <div class="clear"></div>	         	 </div> 	         	 	           <div class="li hidden"  >	            	<div class="li-input-text">使用提醒</div>		            <div class="li-input">		              <input maxlength="16"  placeholder=\'卡券使用提醒\' value=\'到店使用时向服务员出示此券\' name=\'notice\'></input>		            </div>		            <div class="clear"></div>	         	</div> 	         	<div class="li"  >	            	<div class="li-input-text">使用须知</div>		            <div class="li-input">		              <input maxlength="16"  placeholder=\'使用须知\' :value=\'cardInfo.base_info.description\' name=\'description\'></input>		            </div>		            <div class="clear"></div>	         	</div> 	         		         	 <div class="li"  >	            	<div class="li-input-text">特权</div>		            <div class="li-input">		            	<textarea maxlength="1024"  placeholder=\'会员卡特权说明\' name="prerogative">{{cardInfo.prerogative}}</textarea>		             		            </div>		            <div class="clear"></div>	         	</div> 	         	       </div>           <div  v-if="is_publish == 1" class="btn w80 disable "   style="margin-left: 10%; margin-top: 20px; margin-bottom: 30px">确认创建会员卡</div>       <div  v-if="is_publish == 0" class="btn w80" v-on:click="publish($event)"  style="margin-left: 10%; margin-top: 20px; margin-bottom: 30px">确认创建会员卡</div>	 </div>	 </form>    <!-- 设置时间段 --></div>';
});

define("./template_js/cardDetail", [], function(require, exports, module) {
    return '<div class="page-content">    <div class="item"  v-if="cardInfo.config">		    <div class="logo"><img :src="store.logo"></div>		    <div class=\'light\'>{{cardInfo.config.base_info.brand_name}}</div>		    <div class=\'title mgt10\'>{{cardInfo.config.base_info.title}}</div>		    <div class="qrcode">		    	  <img :src="show_qrcode_url" style="min-width: 200px">		    </div>		   		    <div class=\'info light\'>{{cardInfo.config.base_info.description}}</div>		    		    <div   :data-idx="cardInfo.id">		       <a :href="downUrl"  class="btn">免费申请卡券</a>		       <div  v-on:click=\'share($event)\' class="btn btn2">分享给好友</div>		    </div>		          </div></div>';
});

define("./template_js/chooseAppid", [], function(require, exports, module) {
    return "<div class=\"page-content\">	<div class=\"page-title\">选择公众号</div>    <div class=\"item\"  style=\"padding: 15px 0px\"  >		        	   <router-link  v-for=\"item in list\" :to=\"{ name: name, params: { appid: item.appid,id:0 }}\"     class='charge-item1 clearfix' >		      {{item.name}} <img class='arrowright' src='/apps/wx-card/images/arrowright.png' />		    </router-link>		    <router-link :to=\"{ name: name, params: { appid: '0' ,id:0}}\"     class='charge-item1 clearfix color_2' >		      我没有公众号,使用平台公众号创建  <img class='arrowright' src='/apps/wx-card/images/arrowright.png' />		    </router-link>		     <div   v-on:click='addWxApp($event)'   class='charge-item1 clearfix color_0' style=\"border: none; padding-bottom: 8px;\" >		      添加公众号  <img class='arrowright' src='/apps/wx-card/images/arrowright.png' />		    </div>   </div>  </div>";
});

define("./template_js/index", [], function(require, exports, module) {
    return '<div class="page-content"><section class="errormsgDiv"   v-if="nodata">    <p class="errormsg">（￣︶￣）/</p>    <p class="errormsg2">您还没有创建优惠券哦</p> </section>    <div class="item" v-else    v-for="cardInfo in items" >		    <div class="logo"><img :src="store.logo"></div>		    <div class=\'light\'>{{cardInfo.config.base_info.brand_name}}</div>		    <div class=\'title mgt10\'>{{cardInfo.config.base_info.title}}</div>		    <div class=\'info light\' > {{cardInfo.time_limit_str}} </div>		    <div class="">		    	   <router-link :to="{ name: \'cardDetail\', params: { id: cardInfo.id }}"  class="btn btn2">投放</router-link>		    	   	 <div v-on:click="deleteCard($event)"   :data-id="cardInfo.id" :data-appid="cardInfo.appid"  :data-card_id="cardInfo.cardId"  class="btn btn3" >删除</div>		    </div>		   		     <div class=\'info light\'>{{cardInfo.config.base_info.description}}</div>		     <a class=\'charge-item clearfix\' >		      <div class="charge-item-left">人传人优惠券</div>		        		         <div   class="charge-item-right"  v-on:click=\'setCommission($event)\'  :data-title="cardInfo.config.base_info.title" :data-idx="cardInfo.id" :data-commission_money="cardInfo.commission_money">设置</div>		        <img class=\'arrowright\' src=\'/apps/wx-card/images/arrowright.png\' />		        <div class="clear"></div>		          <div class=\'light mgt5\'>奖金=消费金额*奖金比率 <span  v-if="cardInfo.commission_money>0">({{cardInfo.commission_money}}%)</span></div>		          <div class="clear"></div>		     </a>		         </div>  <div style="height: 80px"></div> <router-link :to="{ name: \'chooseAppid\', params: { type: \'addCard\' ,id:0}}"     class="btn w100 fixBox">创建优惠券</router-link><!-- 人传人优惠券 -->	 <form class="popup" id="popup_commission" style="background-color: #fff;">	 	<div class="popup-title">{{title}}</div>	 	  <div class="list-li">	       	         	 <div class="li"  >	            	<div class="li-input-text">奖金比例</div>		            <div class="li-input">		              <input  maxlength="2" type="number" placeholder=\'填20就是20%\' :value=\'commission_money\' id=\'commission_money\'></input>		            </div>		            <div class="clear"></div>	         	 </div> 	     </div>	         	         <div   class="btn w80" v-on:click="saveCommission($event)" style="margin-left: 10%; margin-top: 20px; margin-bottom: 30px">保存</div>	 </form>    <!-- 人传人优惠券 --></div>';
});

define("./template_js/memberCard", [], function(require, exports, module) {
    return '<div class="page-content"><section class="errormsgDiv"   v-if="nodata">    <p class="errormsg">（￣︶￣）/</p>    <p class="errormsg2">您还没有创建会员卡哦</p> </section><div v-else  v-for="cardInfo in items">    <div class="item"  style="margin-bottom:0px" >		    <div class="logo"><img :src="store.logo"></div>		    <div class=\'light\'>{{cardInfo.config.base_info.brand_name}}</div>		    <div class=\'title mgt10\'>{{cardInfo.config.base_info.title}}</div>		    <div class=\'info light\' > {{cardInfo.time_limit_str}} </div>		    <div class="">		    	  <router-link :to="{ name: \'cardDetail\', params: { id: cardInfo.id }}"  class="btn btn2">投放</router-link>		    	  <div v-on:click="more($event)"   :data-id="cardInfo.id" :data-appid="cardInfo.appid"  :data-card_id="cardInfo.cardId"  class="btn btn3" >设置</div>		    </div>		   		    <div class=\'info light\'>{{cardInfo.config.base_info.description}}</div>		     <div class=\'info light\'>{{cardInfo.config.prerogative}}</div>   </div>    <div class="detailBox" v-if="memberCardDetail">		   <!--  <div>会员总数</div>		    <div>90</div> -->		    <ul class="table-li" >		    	<li>		    		<p class="light">新用户数<p>		    		<p>{{memberCardDetail.new_user}}</p>		    	</li>		    	<li>		    		<p class="light">会员总数<p>		    		<p>{{memberCardDetail.total_user}}</p>		    	</li>		    	<li>		    		<p class="light">浏览人数<p>		    		<p>{{memberCardDetail.view_user}}</p>		    	</li>		    	<div class="clear"></div>		    </ul>		    <router-link class="color_0" :to="{ name: \'memberList\', params: { card_id: cardInfo.cardId }}">查看会员</router-link>	</div> 	 <div class="detailBox" v-else>	    <router-link class="color_0" :to="{ name: \'memberList\', params: { card_id: cardInfo.cardId }}">查看会员</router-link>	</div></div>		        <div style="height: 80px"></div> <router-link v-if="showAddMemberCard"  :to="{ name: \'chooseAppid\', params: { type: \'addMemberCard\' }}"     class="btn w100 fixBox">创建会员卡</router-link>       </div>';
});

define("./template_js/memberList", [], function(require, exports, module) {
    return '<div class="page-content"> 	 	<div class="J_search_trigger">      <input type="text"  id="keyword" placeholder=\'支持手机号，姓名搜索\' v-on:blur="search($event)"   />	</div>	<div v-if="items.length">    <div   class="item-list" v-for="userInfo in items"  style="margin-bottom:0px" >		    <div class="image"><img :src="userInfo.member_store.avatarUrl"></div>		    <div class="item-body">		    	<div class=\'title\'>{{userInfo.name}} ({{userInfo.member_store.user_tag_str}})</div>			    <div class=\'light mgt5\'>{{userInfo.phone}}</div>			    <div class=\'info light mgt5\'>			    	<span>积分:{{userInfo.member_store.credits}}</span>  			    	<span class=\'pd5-h\'>•</span> 			    	<span>余额:{{userInfo.member_store.money}}</span>   			    </div>		    </div>		    <div class="clear"></div>   </div> </div>    <div v-else style=" text-align: center;padding: 10px;">  	 没有查到相关数据  </div>         </div>';
});

define("./template_js/opencard", [], function(require, exports, module) {
    return '<div class="page-content"> </div>';
});
